結果

問題 No.1703 Much Matching
ユーザー publflpublfl
提出日時 2021-10-08 22:49:44
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,130 bytes
コンパイル時間 534 ms
コンパイル使用メモリ 55,948 KB
実行使用メモリ 20,432 KB
最終ジャッジ日時 2023-09-30 11:57:17
合計ジャッジ時間 4,006 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
9,088 KB
testcase_01 AC 3 ms
9,152 KB
testcase_02 AC 3 ms
9,152 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 80 ms
14,356 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 15 ms
9,268 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 3 ms
9,180 KB
testcase_15 WA -
testcase_16 AC 53 ms
13,884 KB
testcase_17 WA -
testcase_18 AC 3 ms
9,044 KB
testcase_19 WA -
testcase_20 AC 17 ms
11,288 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 4 ms
9,096 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 297 ms
20,432 KB
testcase_37 AC 3 ms
9,036 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <vector>
#include <algorithm>

int C = 1;
std::pair<int,int> P[1000010];

int check[1000010];
int next[1000010],prev[1000010];
std::vector< std::pair<int,int> > temp;
int main()
{
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	for(int i=1;i<=c;i++) scanf("%d%d",&P[i].first,&P[i].second);
	std::sort(P+1,P+c+1);
	
	for(int i=1;i<=c;i++)
	{
		if(P[i].first!=P[i-1].first) prev[i] = i;
		else prev[i] = prev[i-1];
	}
	for(int i=c;i>=1;i--)
	{
		if(P[i].first!=P[i+1].first) next[i] = i;
		else next[i] = next[i+1];
	}
	
	for(int i=1;i<=c;i++)
	{
		if(i==next[i])
		{
			for(int j=prev[i];j<=i;j++)
			{
				int min = 1, max = C-1;
				int p = 0;
				while(min<=max)
				{
					int h = (min+max)/2;
					if(check[h]<P[i].second)
					{
						p = h;
						min = h+1;
					}
					else max = h-1;
				}
				temp.push_back(std::make_pair(p+1,P[j].second));
			}
			
			while(!temp.empty())
			{
				std::pair<int,int> t = temp.back();
				temp.pop_back();
				if(t.first==C) C++, check[t.first] = t.second;
				else check[t.first] = check[t.first]<t.second?check[t.first]:t.second;
			}
		}
	}
	
	printf("%d",C-1);
}
0