結果
問題 | No.1647 Travel in Mitaru city 2 |
ユーザー | たたき@競プロ |
提出日時 | 2023-08-30 06:50:44 |
言語 | C++23 (gcc 12.3.0 + boost 1.83.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,208 bytes |
コンパイル時間 | 8,001 ms |
コンパイル使用メモリ | 314,516 KB |
実行使用メモリ | 35,132 KB |
最終ジャッジ日時 | 2023-08-30 06:51:18 |
合計ジャッジ時間 | 33,568 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,380 KB |
testcase_01 | RE | - |
testcase_02 | AC | 1 ms
4,380 KB |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | AC | 2 ms
4,380 KB |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | AC | 363 ms
32,432 KB |
testcase_09 | AC | 300 ms
30,196 KB |
testcase_10 | AC | 329 ms
32,632 KB |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | AC | 363 ms
33,508 KB |
testcase_15 | AC | 344 ms
33,008 KB |
testcase_16 | AC | 348 ms
31,536 KB |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | AC | 371 ms
34,244 KB |
testcase_23 | AC | 366 ms
34,292 KB |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | AC | 399 ms
34,460 KB |
testcase_27 | AC | 370 ms
34,360 KB |
testcase_28 | AC | 380 ms
35,124 KB |
testcase_29 | AC | 402 ms
35,128 KB |
testcase_30 | WA | - |
testcase_31 | AC | 403 ms
35,124 KB |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | AC | 398 ms
35,096 KB |
testcase_35 | AC | 330 ms
32,612 KB |
testcase_36 | AC | 372 ms
35,060 KB |
testcase_37 | AC | 368 ms
35,132 KB |
testcase_38 | AC | 334 ms
30,216 KB |
testcase_39 | WA | - |
testcase_40 | AC | 344 ms
30,220 KB |
testcase_41 | WA | - |
testcase_42 | AC | 362 ms
30,144 KB |
testcase_43 | RE | - |
testcase_44 | AC | 5 ms
7,836 KB |
testcase_45 | AC | 285 ms
24,100 KB |
testcase_46 | RE | - |
testcase_47 | AC | 270 ms
24,204 KB |
testcase_48 | AC | 288 ms
24,196 KB |
testcase_49 | AC | 288 ms
24,372 KB |
testcase_50 | WA | - |
ソースコード
#include<bits/stdc++.h> using namespace std; #include <atcoder/all> using namespace atcoder; using mint=modint998244353; //1000000007; using ll=long long; using pp=pair<int,int>; #define sr string #define vc vector #define fi first #define se second #define rep(i,n) for(int i=0;i<(int)n;i++) #define pb push_back #define all(v) v.begin(),v.end() #define pque priority_queue #define bpc(a) __builtin_popcount(a) int main(){ int h,w,n;cin>>h>>w>>n; vc v(h+w,vc<int>(0)); map<pp,int>m; rep(i,n){ int x,y;cin>>x>>y; x--; y--; v[x].pb(h+y); v[h+y].pb(x); m[{x,y+h}]=i; m[{y+h,x}]=i; } vc<bool>ch(h+w,false); vc<int>ans; auto f=[&](auto f,int a,int p)->int{ if(ch[a])return a; ch[a]=true; int res=-1; for(auto au:v[a])if(au!=p){ res=f(f,au,a); if(res!=-1)break; } if(res!=-1)ans.pb(a); if(res==a)res=-1; return res; }; rep(i,h)if(!ch[i]){ f(f,i,-1); if(ans.size())break; } cout<<ans.size()<<"\n"; if(ans[0]>=h){ ans.pb(ans[0]); ans.pb(ans[1]); for(int i=1;i<ans.size()-1;i++)cout<<m[{ans[i],ans[i+1]}]+1<<' '; } else{ ans.pb(ans[0]); rep(i,ans.size()-1)cout<<m[{ans[i],ans[i+1]}]+1<<' '; } }