結果
| 問題 |
No.1315 渦巻洞穴
|
| コンテスト | |
| ユーザー |
Haa
|
| 提出日時 | 2020-12-12 21:00:18 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,886 bytes |
| コンパイル時間 | 1,729 ms |
| コンパイル使用メモリ | 170,264 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-19 22:16:49 |
| 合計ジャッジ時間 | 11,333 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 WA * 2 |
| other | AC * 20 WA * 59 |
コンパイルメッセージ
main.cpp: In function 'std::pair<int, int> point(int)':
main.cpp:44:1: warning: control reaches end of non-void function [-Wreturn-type]
44 | }
| ^
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
#define REP(i,n) for(int i=0;i<n;i++)
#define ALL(v) v.begin(),v.end()
constexpr ll MOD=998244353;
constexpr ll INF=1e18;
pair<int,int> point(int n){
if(n==1)
return {0,0};
ll k;
for(k=1;1;k+=2){
if(k*k>n){
k-=2;
break;
}
}
int now=k*k;
int x=(k+1)/2, y=(k+1)/2;
REP(i,k+1){
y--; now++;
if(now==n)
return {x,y};
}
REP(i,k+1){
x--; now++;
if(now==n)
return {x,y};
}
REP(i,k+1){
y++; now++;
if(now==n)
return {x,y};
}
REP(i,k+1){
x++; now++;
if(now==n)
return {x,y};
}
}
string path(int dx, int dy){
string ret="";
if(dx>0){
REP(i,dx/2)
ret+="RRLR";
}
else{
REP(i,-dx/2)
ret+="LLRL";
}
if(dy>0){
REP(i,dy/2)
ret+="DDUD";
}
else{
REP(i,-dy/2)
ret+="UUDU";
}
return ret;
}
int main(){
int s, t; cin >> s >> t;
pair<int,int> sp=point(s), tp=point(t);
string ans="RLR";
sp.first++;
int dx=tp.first-sp.first, dy=tp.second-sp.second;
if(abs(dx)%2==0&&abs(dy)%2==0){
ans+=path(dx,dy);
}
else{
if(sp.second%2!=tp.second%2){
ans+="RDUD";
sp.first++;
sp.second++;
}
if(sp.first%2!=tp.first%2){
if(sp.second%2==0){
if(sp.first%2==0){
dx=-2-sp.first;
dy=-sp.second;
ans+=path(dx,dy);
ans+="UUR";
sp.first+=dx+1;
sp.second+=dy-2;
}
else{
dx=-1-sp.first;
dy=-2-sp.second;
ans+=path(dx,dy);
ans+="LDD";
sp.first+=dx-1;
sp.second+=dy+2;
}
}
else{
if(sp.first%2==0){
dx=-sp.first;
dy=-1-sp.second;
ans+=path(dx,dy);
ans+="LDD";
sp.first+=dx-1;
sp.second+=dy+2;
}
else{
dx=-1-sp.first;
dy=1-sp.second;
ans+=path(dx,dy);
ans+="UUR";
sp.first+=dx+1;
sp.second+=dy-2;
}
}
}
dx=tp.first-sp.first;
dy=tp.second-sp.second;
ans+=path(dx,dy);
}
cout << 0 << endl;
cout << ans.size() << endl;
cout << ans << endl;
return 0;
}
Haa