結果
| 問題 | No.3544 Robot on Torus (C++) |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-04-12 00:32:11 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 24 ms / 2,000 ms |
| コード長 | 531 bytes |
| 記録 | |
| コンパイル時間 | 2,298 ms |
| コンパイル使用メモリ | 337,700 KB |
| 実行使用メモリ | 9,472 KB |
| スコア | 126 |
| 最終ジャッジ日時 | 2026-05-16 15:00:35 |
| 合計ジャッジ時間 | 6,763 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 27 |
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:18:11: warning: 'ri' may be used uninitialized [-Wmaybe-uninitialized]
18 | memo[i][j]=1;
| ^
main.cpp:8:7: note: 'ri' was declared here
8 | int ri,rj;
| ^~
main.cpp:19:25: warning: 'rj' may be used uninitialized [-Wmaybe-uninitialized]
19 | int ni=(i+1)%h,nj=(j+1)%w;
| ~~^~~
main.cpp:8:10: note: 'rj' was declared here
8 | int ri,rj;
| ^~
ソースコード
#include<bits/stdc++.h>
using namespace std;
int main(){
int h,w;
cin>>h>>w;
vector<string> s(h);
for(auto& s_i:s) cin>>s_i;
int ri,rj;
for(int i=0;i<h;i++) for(int j=0;j<w;j++){
if(s[i][j]=='R'){
ri=i;
rj=j;
}
}
vector memo(h,vector<int>(w,0));
int i=ri,j=rj;
while(true){
memo[i][j]=1;
int ni=(i+1)%h,nj=(j+1)%w;
if(memo[ni][nj]) break;
if(s[ni][nj]=='#') break;
i=ni;
j=nj;
}
if(s[(i+1)%h][(j+1)%w]=='#') cout<<i+1<<" "<<j+1<<endl;
else cout<<"loop"<<endl;
}