結果
| 問題 |
No.1328 alligachi-problem
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-12-25 20:12:09 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 132 ms / 2,000 ms |
| コード長 | 1,191 bytes |
| コンパイル時間 | 1,008 ms |
| コンパイル使用メモリ | 85,156 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-09-22 13:42:58 |
| 合計ジャッジ時間 | 7,164 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 25 |
コンパイルメッセージ
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)));
}
sort(G[0].begin(),G[0].end(),[](pair<int,pair<int,int> >a,pair<int,pair<int,int> >b)
{
if(a.first!=b.first)return a.first<b.first;
else return a.second>b.second;
});
sort(G[1].begin(),G[1].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":" ");
}