結果
| 問題 |
No.1074 増殖
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-06-05 22:07:46 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 129 ms / 2,000 ms |
| コード長 | 807 bytes |
| コンパイル時間 | 821 ms |
| コンパイル使用メモリ | 82,132 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-12-17 15:23:29 |
| 合計ジャッジ時間 | 2,611 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 12 |
コンパイルメッセージ
main.cpp:8:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
8 | main()
| ^~~~
ソースコード
#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;
}
}