結果
| 問題 | No.3544 Robot on Torus (C++) |
| コンテスト | |
| ユーザー |
titia
|
| 提出日時 | 2026-05-21 01:35:46 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 22 ms / 2,000 ms |
| コード長 | 476 bytes |
| 記録 | |
| コンパイル時間 | 1,350 ms |
| コンパイル使用メモリ | 214,532 KB |
| 実行使用メモリ | 6,400 KB |
| スコア | 181 |
| 最終ジャッジ日時 | 2026-05-21 01:35:53 |
| 合計ジャッジ時間 | 6,512 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 27 |
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:26:27: warning: 'x' may be used uninitialized [-Wmaybe-uninitialized]
26 | if (MAP[(x+1)%h][(y+1)%w]!='#'){
| ~~^~~
main.cpp:14:13: note: 'x' was declared here
14 | int x,y;
| ^
main.cpp:26:36: warning: 'y' may be used uninitialized [-Wmaybe-uninitialized]
26 | if (MAP[(x+1)%h][(y+1)%w]!='#'){
| ~~^~~
main.cpp:14:15: note: 'y' was declared here
14 | int x,y;
| ^
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main(){
int h,w;
cin >> h >> w;
vector<string> MAP(h);
for (int i=0;i<h;i++){
cin>>MAP[i];
}
int x,y;
for (int i=0;i<h;i++){
for (int j=0;j<w;j++){
if (MAP[i][j]=='R'){
x=i;
y=j;
}
}
}
for (int tests=0;tests<1000000;tests++){
if (MAP[(x+1)%h][(y+1)%w]!='#'){
x=(x+1)%h;
y=(y+1)%w;
}
else{
cout<<x+1<<" "<<y+1<<endl;
return 0;
}
}
cout<<"loop"<<endl;
return 0;
}
titia