結果
問題 | No.232 めぐるはめぐる (2) |
ユーザー | 沙耶花 |
提出日時 | 2021-11-18 18:58:51 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 328 ms / 1,000 ms |
コード長 | 1,648 bytes |
コンパイル時間 | 4,338 ms |
コンパイル使用メモリ | 255,708 KB |
最終ジャッジ日時 | 2025-01-25 19:20:16 |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:42:42: warning: ‘k’ may be used uninitialized [-Wmaybe-uninitialized] 42 | ans.push_back(s[k]); | ^ main.cpp:26:29: note: ‘k’ was declared here 26 | int k; | ^ main.cpp:80:58: warning: ‘k’ may be used uninitialized [-Wmaybe-uninitialized] 80 | ans.push_back(s[k]); | ^ main.cpp:64:45: note: ‘k’ was declared here 64 | int k; | ^
ソースコード
#include <stdio.h> #include <bits/stdc++.h> #include <atcoder/all> using namespace atcoder; using mint = modint1000000007; using namespace std; #define rep(i,n) for (int i = 0; i < (n); ++i) #define Inf 1000000001 int main(){ vector dx = {1,1,0,-1,-1,-1,0,1}, dy = {0,1,1,1,0,-1,-1,-1}; vector<string> s = {">",">^","^","^<","<","<v","v","v>"}; int T,A,B; cin>>T>>A>>B; swap(A,B); rep(i,8){ int a = 0,b = 0; vector<string> ans(1,s[i]); a += dx[i]; b += dy[i]; rep(j,T-1){ int k; if(a==A&&b==B)k = 0; else if(a==A){ if(b<B)k = 2; else k = 6; } else if(b==B){ if(a<A)k = 0; else k = 4; } else{ if(a<A&&b<B)k = 1; if(a>A&&b<B)k = 3; if(a>A&&b>B)k = 5; if(a>A&&b>B)k = 7; } ans.push_back(s[k]); a += dx[k]; b += dy[k]; //if(i==1)cout<<k<<endl; } if(a==A&&b==B){ cout<<"YES"<<endl; rep(i,T)cout<<ans[i]<<endl; return 0; } } if(T>=2){ rep(i,8){ rep(ii,8){ int a = 0,b = 0; vector<string> ans(1,s[i]); a += dx[i]; b += dy[i]; ans.push_back(s[ii]); a += dx[ii],b += dy[ii]; rep(j,T-2){ int k; if(a==A&&b==B)k = 0; else if(a==A){ if(b<B)k = 2; else k = 6; } else if(b==B){ if(a<A)k = 0; else k = 4; } else{ if(a<A&&b<B)k = 1; if(a>A&&b<B)k = 3; if(a>A&&b>B)k = 5; if(a>A&&b>B)k = 7; } ans.push_back(s[k]); a += dx[k]; b += dy[k]; //if(i==1)cout<<k<<endl; } if(a==A&&b==B){ cout<<"YES"<<endl; rep(i,T)cout<<ans[i]<<endl; return 0; } } } } cout<<"NO"<<endl; return 0; }