結果

問題 No.1328 alligachi-problem
ユーザー kotatsugamekotatsugame
提出日時 2020-12-25 20:12:09
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 131 ms / 2,000 ms
コード長 1,191 bytes
コンパイル時間 1,625 ms
コンパイル使用メモリ 84,976 KB
実行使用メモリ 6,868 KB
最終ジャッジ日時 2023-10-23 20:02:28
合計ジャッジ時間 7,863 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 3 ms
4,348 KB
testcase_06 AC 3 ms
4,348 KB
testcase_07 AC 3 ms
4,348 KB
testcase_08 AC 3 ms
4,348 KB
testcase_09 AC 129 ms
6,664 KB
testcase_10 AC 107 ms
5,892 KB
testcase_11 AC 130 ms
6,668 KB
testcase_12 AC 129 ms
6,664 KB
testcase_13 AC 129 ms
6,664 KB
testcase_14 AC 129 ms
6,860 KB
testcase_15 AC 108 ms
6,084 KB
testcase_16 AC 130 ms
6,668 KB
testcase_17 AC 129 ms
6,864 KB
testcase_18 AC 129 ms
6,664 KB
testcase_19 AC 130 ms
6,664 KB
testcase_20 AC 131 ms
6,856 KB
testcase_21 AC 130 ms
6,856 KB
testcase_22 AC 130 ms
6,868 KB
testcase_23 AC 107 ms
6,084 KB
testcase_24 AC 107 ms
6,664 KB
testcase_25 AC 107 ms
6,856 KB
testcase_26 AC 109 ms
6,856 KB
testcase_27 AC 108 ms
6,856 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:7:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    7 | main()
      | ^~~~

ソースコード

diff #

#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":" ");
}
0