UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#212255#3811. T1sublimetextCompile Error//C++1.5kb2024-10-13 16:10:012024-10-13 19:36:41

answer

#include <bits/stdc++.h>
using namespace std;
#define LL __int128
#define ll long long
#define uLL __uint128_t
#define ull unsigned long long
#define REP(i, l, r) for(int i = l; i <= r; ++i)
#define PER(i, r, l) for(int i = r; i >= l; --i)
namespace ink {
	const int N = 2e6+5;
	int Q;
	struct A{
		int op,d,x,y;
	} q[N];
	struct node {
		int x,y;
		bool operator < (const node&it) const {
			return x+y==it.x+it.y?x + y < it.x + it.y:x < it.x;
		}
	};
	multiset<node> S[2];
	struct Tnode {
		int x, y;
		bool operator < (const Tnode&it) const {
			return x != it.x ? x < it.x : y < it.y;
		}
	};
	multiset<Tnode> T[2];
	int main() {
		ios::sync_with_stdio(false);
		cin.tie(0), cout.tie(0);
		cin>>Q;
		int O = (int)2e8 / Q;
		REP(i,1,Q) {
			cin>>q[i].op>>q[i].d>>q[i].x>>q[i].y;
			if(q[i].op==1) {
				S[q[i].d].insert({q[i].x,q[i].y});
				T[q[i].d].insert({q[i].x,q[i].y});
			}
			else { 
				S[q[i].d].erase(S[q[i].d].find({q[i].x,q[i].y}));
				T[q[i].d].erase(T[q[i].d].find({q[i].x,q[i].y}));
			}
			if(S[0].empty()||S[1].empty()) {
				cout<<-1<<'\n';
				continue;
			}
			int ans=max(S[0].begin()->x+S[1].begin()->x, S[0].begin()->y+S[1].begin()->y);
			ans=min(ans,
					max(T[0].begin()->x+T[1].begin()->x, T[0].begin()->y+T[1].begin()->y));
			for(auto&i:S[0]) {
				int CNT = 0;
				for(auto&j:S[1]) {
					ans=min(ans,max(i.x+j.x,i.y+j.y));
					++CNT;
					if(CNT >= O) break;
				}
			}
			cout<<ans<<'\n';
		}

		return 0;
	}
}

signed main() {return ink::main();}

详细

answer.code: In function 'int ink::main()':
answer.code:37:21: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11 [enabled by default]
     S[q[i].d].insert({q[i].x,q[i].y});\x0d
                     ^
answer.code:37:37: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11 [enabled by default]
     S[q[i].d].insert({q[i].x,q[i].y});\x0d
                                     ^
answer.code:38:21: warning: extended initializer lists only availa...