QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#225365 | #7521. Find the Gap | PetroTarnavskyi# | WA | 0ms | 3556kb | C++17 | 1.8kb | 2023-10-24 16:04:36 | 2023-10-24 16:04:36 |
Judging History
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