結果
問題 |
No.1328 alligachi-problem
|
ユーザー |
|
提出日時 | 2020-12-25 20:02:31 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,038 bytes |
コンパイル時間 | 992 ms |
コンパイル使用メモリ | 82,820 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-22 13:36:17 |
合計ジャッジ時間 | 7,045 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 10 WA * 15 |
コンパイルメッセージ
main.cpp:7:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 7 | main() | ^~~~
ソースコード
#include<iostream> #include<algorithm> #include<vector> using namespace std; int N; vector<pair<int,pair<int,int> > >G[2]; main() { cin>>N; for(int i=1;i<=N;i++) { char c,x;int y;cin>>c>>x>>y; G[x=='R'].push_back(make_pair(y,make_pair(c=='R',i))); } for(int i=0;i<2;i++)sort(G[i].begin(),G[i].end()); vector<int>ans;ans.reserve(N); int i0=0,i1=0; int c[2]={}; while(i0<G[0].size()||i1<G[1].size()) { bool f0=false,f1=false; if(i0<G[0].size()&&c[0]==G[0][i0].first)f0=true; if(i1<G[1].size()&&c[1]==G[1][i1].first)f1=true; if(f0&&f1) { if(G[0][i0].second.first==G[1][i1].second.first) { if(G[0][i0].second.first==0) { f1=false; } else { f0=false; } } } if(f0) { c[G[0][i0].second.first]++; ans.push_back(G[0][i0++].second.second); } else if(f1) { c[G[1][i1].second.first]++; ans.push_back(G[1][i1++].second.second); } else { cout<<"No"<<endl; return 0; } } cout<<"Yes"<<endl; for(int i=0;i<N;i++)cout<<ans[i]<<(i+1==N?"\n":" "); }