結果

問題 No.1074 増殖
ユーザー kotatsugamekotatsugame
提出日時 2020-06-05 22:07:46
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 128 ms / 2,000 ms
コード長 807 bytes
コンパイル時間 752 ms
コンパイル使用メモリ 81,112 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-05-09 21:26:53
合計ジャッジ時間 2,551 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 109 ms
6,944 KB
testcase_07 AC 105 ms
6,944 KB
testcase_08 AC 103 ms
6,940 KB
testcase_09 AC 115 ms
6,940 KB
testcase_10 AC 107 ms
6,940 KB
testcase_11 AC 102 ms
6,940 KB
testcase_12 AC 103 ms
6,940 KB
testcase_13 AC 128 ms
6,940 KB
testcase_14 AC 127 ms
6,944 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:8:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    8 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
using namespace std;
int N;
set<pair<int,int> >S[4];
main()
{
	for(int i=0;i<4;i++)
	{
		S[i].insert(make_pair(0,1e5));
		S[i].insert(make_pair(1e5,0));
	}
	cin>>N;
	for(;N--;)
	{
		int Xa,Ya,Xb,Yb;
		cin>>Xa>>Ya>>Xb>>Yb;
		int X[4]={Xb,-Xa,-Xa,Xb};
		int Y[4]={Yb,Yb,-Ya,-Ya};
		int ans=0;
		for(int i=0;i<4;i++)
		{
			set<pair<int,int> >::iterator it=S[i].lower_bound(make_pair(X[i],0));
			if(it->second>=Y[i])continue;
			int py=it->second;
			if(it->first==X[i])it=S[i].erase(it);
			it--;
			int pre=X[i];
			while(true){
				ans+=(Y[i]-py)*(pre-it->first);
				if(it->second>Y[i])break;
				py=it->second;
				pre=it->first;
				it=S[i].erase(it);
				it--;
			}
			S[i].insert(make_pair(X[i],Y[i]));
		}
		cout<<ans<<endl;
	}
}
0