結果
| 問題 |
No.1328 alligachi-problem
|
| コンテスト | |
| ユーザー |
Chanyuh
|
| 提出日時 | 2020-12-29 18:13:16 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,988 bytes |
| コンパイル時間 | 1,482 ms |
| コンパイル使用メモリ | 133,964 KB |
| 最終ジャッジ日時 | 2025-01-17 08:20:19 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 24 WA * 1 |
ソースコード
#include<iostream>
#include<array>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
#include<cassert>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
typedef pair<P,int> PP;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
template<class T>bool chmax(T &a, const T &b) {if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b) {if(b<a){a=b;return 1;}return 0;}
int n;
char c[200010],x[200010];int y[200010];
vector<PP> V[2];
int f(char c){
if(c=='R') return 0;
else return 1;
}
void solve(){
cin >> n;
rep(i,n){
cin >> c[i] >> x[i] >> y[i];
V[f(x[i])].push_back(PP(P(y[i],(f(c[i])+f(x[i])+1)%2),i));
}
rep(i,2) sort(V[i].begin(),V[i].end());
for(auto &pp:V[0]){
pp.first.second=1-pp.first.second;
}
// rep(i,2) for(auto pp:V[i]){
// cout << i << " " << pp.first.second << " " << pp.first.first << endl;
// }
V[0].push_back(PP(P(mod,0),n));
int m=V[1].size();
int pos=0,num[2]={0,0};
vector<int> ans={};
rep(i,m){
//cout << num[0]+(V[1][i].first.second) << " " << num[1] << endl;
while((num[0]+(V[1][i].first.second==0)>V[0][pos].first.first) || (num[1]!=V[1][i].first.first)){
if(num[0]!=V[0][pos].first.first){
cout << "No" << endl;
return;
}
ans.push_back(V[0][pos].second);
num[V[0][pos].first.second]+=1;
pos++;
//cout << pos << endl;
}
ans.push_back(V[1][i].second);
num[V[1][i].first.second]+=1;
}
while(pos<n-m){
if(V[0][pos].first.first!=num[0]){
cout << "No" << endl;
}
num[V[0][pos].first.second]+=1;
ans.push_back(V[0][pos].second);
pos++;
}
int k[2]={0,0};
rep(i,n){
if(k[f(x[ans[i]])]!=y[ans[i]]){
cout << "No" << endl;
return;
}
k[f(c[ans[i]])]+=1;
}
cout << "Yes" << endl;
rep(i,n){
cout << ans[i]+1 << ((i<n-1)?" ":"");
}
cout << "" << endl;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout << fixed << setprecision(50);
solve();
}
Chanyuh