QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#225365#7521. Find the GapPetroTarnavskyi#WA 0ms3556kbC++171.8kb2023-10-24 16:04:362023-10-24 16:04:36

Judging History

你现在查看的是最新测评结果

  • [2023-10-24 16:04:36]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3556kb
  • [2023-10-24 16:04:36]
  • 提交

answer

#include <iostream>
#include <set>
#include <map>

using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (a) - 1; i >= (b); i--)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair
#define F first
#define S second

typedef long long LL;
//typedef vector<int> VI;
typedef pair<int, int> PII;
typedef double db;


map<int, int> cnt[2];

void erase(int t, int x)
{
	cnt[t][x]--;
	if (cnt[t][x] == 0)
		cnt[t].erase(x);
}
	

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	return 0;
	int q;
	cin >> q;
	int last = 0;
	set<pair<int, PII>> s;
	FOR (i, 0, q)
	{
		int t;
		cin >> t;
		if (t == 1)
		{
			int x, y, W;
			cin >> x >> y >> W;
			x ^= last;
			y ^= last;
			W ^= last;
			s.insert({W, {x, y}});
			cnt[0][x]++;
			cnt[1][y]++;
			if (cnt[0].count(x) && cnt[0][x] == 7)
			{
				for (auto [w, p] : s)
				{
					if (p.F == x)
					{
						erase(0, p.F);
						erase(1, p.S);
						s.erase({w, p});
						break;
					}
				}
			}
			if (cnt[1].count(y) && cnt[1][y] == 7)
			{
				for (auto [w, p] : s)
				{
					if (p.S == y)
					{
						erase(0, p.F);
						erase(1, p.S);
						s.erase({w, p});
						break;
					}
				}
			}
			if (SZ(s) > 47)
			{
				auto p = s.begin()->S;
				erase(0, p.F);
				erase(1, p.S);
				s.erase(s.begin());
			}
		}
		else
		{
			int x, y;
			cin >> x >> y;
			x ^= last;
			y ^= last;
			int ans = 0;
			for (auto it = s.end(); ; )
			{
				if (it == s.begin())
					break;
				it--;
				auto [w, p] = *it;
				if (p.F != x && p.S != y)
				{
					ans = w;
					break;
				}
			}
			cout << ans << '\n';
			last = ans;
		}
	}
	
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3556kb

input:

8
1 1 1
1 1 2
1 2 1
1 2 2
2 1 1
2 1 2
2 2 1
2 2 2

output:


result:

wrong output format Unexpected end of file - double expected