結果
問題 | No.240 ナイト散歩 |
ユーザー | ohreitetsu |
提出日時 | 2018-05-26 18:05:24 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,657 bytes |
コンパイル時間 | 673 ms |
コンパイル使用メモリ | 72,996 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-28 18:15:01 |
合計ジャッジ時間 | 1,670 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | AC | 2 ms
5,376 KB |
testcase_04 | AC | 2 ms
5,376 KB |
testcase_05 | AC | 2 ms
5,376 KB |
testcase_06 | AC | 2 ms
5,376 KB |
testcase_07 | AC | 2 ms
5,376 KB |
testcase_08 | AC | 2 ms
5,376 KB |
testcase_09 | AC | 1 ms
5,376 KB |
testcase_10 | AC | 2 ms
5,376 KB |
testcase_11 | AC | 2 ms
5,376 KB |
testcase_12 | AC | 2 ms
5,376 KB |
testcase_13 | AC | 1 ms
5,376 KB |
testcase_14 | AC | 2 ms
5,376 KB |
testcase_15 | AC | 1 ms
5,376 KB |
testcase_16 | AC | 3 ms
5,376 KB |
testcase_17 | AC | 2 ms
5,376 KB |
testcase_18 | AC | 2 ms
5,376 KB |
testcase_19 | AC | 2 ms
5,376 KB |
testcase_20 | AC | 2 ms
5,376 KB |
testcase_21 | AC | 2 ms
5,376 KB |
testcase_22 | AC | 2 ms
5,376 KB |
testcase_23 | AC | 2 ms
5,376 KB |
testcase_24 | AC | 2 ms
5,376 KB |
testcase_25 | AC | 1 ms
5,376 KB |
testcase_26 | AC | 2 ms
5,376 KB |
testcase_27 | AC | 2 ms
5,376 KB |
testcase_28 | AC | 2 ms
5,376 KB |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | AC | 2 ms
5,376 KB |
コンパイルメッセージ
main.cpp: In function 'bool canGoTo(int, int, int&)': main.cpp:66:23: warning: 'yMin' may be used uninitialized [-Wmaybe-uninitialized] 66 | return canGoTo(xMin,yMin,num); | ~~~~~~~^~~~~~~~~~~~~~~ main.cpp:54:18: note: 'yMin' was declared here 54 | int xMin,yMin; | ^~~~ main.cpp:66:23: warning: 'xMin' may be used uninitialized [-Wmaybe-uninitialized] 66 | return canGoTo(xMin,yMin,num); | ~~~~~~~^~~~~~~~~~~~~~~ main.cpp:54:13: note: 'xMin' was declared here 54 | int xMin,yMin; | ^~~~
ソースコード
#include <iostream> #include <vector> using namespace std; typedef long long LL; int X,Y; LL dist(int x1,int y1,int x2,int y2){ return (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2); } bool canGoTo(int x,int y,int &num) { if (x==X && y==Y){ cout<<"YES"<<endl; return true; } vector<pair<int,int>> myVec; myVec.push_back(make_pair(x-2,y-1)); myVec.push_back(make_pair(x-2,y)); myVec.push_back(make_pair(x-2,y+1)); myVec.push_back(make_pair(x-1,y-2)); myVec.push_back(make_pair(x-1,y-1)); myVec.push_back(make_pair(x-1,y)); myVec.push_back(make_pair(x-1,y+1)); myVec.push_back(make_pair(x-1,y+2)); myVec.push_back(make_pair(x,y-2)); myVec.push_back(make_pair(x,y-1)); myVec.push_back(make_pair(x,y)); myVec.push_back(make_pair(x,y+1)); myVec.push_back(make_pair(x,y+2)); myVec.push_back(make_pair(x+1,y-2)); myVec.push_back(make_pair(x+1,y-1)); myVec.push_back(make_pair(x+1,y)); myVec.push_back(make_pair(x+1,y+1)); myVec.push_back(make_pair(x+1,y+2)); myVec.push_back(make_pair(x+2,y-1)); myVec.push_back(make_pair(x+2,y)); myVec.push_back(make_pair(x+2,y+1)); int i; for (i=0;i<myVec.size();i++){ if (myVec[i].first==X && myVec[i].second==Y){ myVec.clear(); cout<<"YES"<<endl; return true; } } num++; if (num==3){ cout<<"NO"<<endl; return false; } int xMin,yMin; LL distMin=1e18; LL distXY; for (i=0;i<myVec.size();i++){ distXY=dist(X,Y,myVec[i].first,myVec[i].second); if (distMin>distXY){ distMin=distXY; xMin=myVec[i].first; yMin=myVec[i].second; } } myVec.clear(); return canGoTo(xMin,yMin,num); } int main(int argc, char* argv[]) { cin>>X>>Y; int num=0; canGoTo(0,0,num); return 0; }