結果
問題 |
No.240 ナイト散歩
|
ユーザー |
|
提出日時 | 2024-11-25 01:12:06 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 817 bytes |
コンパイル時間 | 2,038 ms |
コンパイル使用メモリ | 201,164 KB |
最終ジャッジ日時 | 2025-02-25 06:10:52 |
ジャッジサーバーID (参考情報) |
judge1 / judge1 |
外部呼び出し有り |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:34:28: warning: ignoring return value of ‘int system(const char*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 34 | int main() { solve();system("pause"); } | ~~~~~~^~~~~~~~~
ソースコード
#include <bits/stdc++.h> using namespace std; typedef int64_t ll; void solve() { cin.tie(nullptr); ios::sync_with_stdio(false); ll x,y; cin>>x>>y; deque<tuple<ll,ll,ll>> que; que.push_back(make_tuple(0,0,0)); while(!que.empty()){ auto [a,b,c]=que.front(); que.pop_front(); if(a==x&&b==y){ cout<<"YES"<<endl; return; } if(c!=3){ que.push_back(make_tuple(a-2,b-1,c+1)); que.push_back(make_tuple(a-1,b-2,c+1)); que.push_back(make_tuple(a+1,b+2,c+1)); que.push_back(make_tuple(a+2,b+1,c+1)); que.push_back(make_tuple(a-2,b+1,c+1)); que.push_back(make_tuple(a-1,b+2,c+1)); que.push_back(make_tuple(a+1,b-2,c+1)); que.push_back(make_tuple(a+2,b-1,c+1)); } } cout<<"NO"<<endl; } int main() { solve();system("pause"); }