QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#374681#8305. AcceleratorPetroTarnavskyi#RE 0ms0kbC++201.4kb2024-04-02 16:53:132024-04-02 16:53:14

Judging History

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

  • [2024-04-02 16:53:14]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2024-04-02 16:53:13]
  • 提交

answer

#include <bits/stdc++.h>

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;

const int LOG = 8;
const int M = 1 << LOG;

int lastPos[M];
int win[M];

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	fill(lastPos, lastPos + M, -1);
	int n, m;
	cin >> n >> m;
	FOR(i, 0, n)
	{
		int a;
		cin >> a;
		lastPos[a] = i;
	}
	set<PII> s;
	FOR(x, 0, M)
	{
		if (lastPos[x] != -1)
		{
			s.insert({-lastPos[x], x});
		}
	}
	auto calcWin = [&]()
	{
		fill(win, win + M, -1);
		for (auto [i, x] : s)
		{
			if (win[x] != -1)
			{
				assert(win[x] == 1);
				continue;
			}
			win[x] = 0;
			FOR(j, 0, LOG)
			{
				int y = x ^ (1 << j);
				if (win[y] == -1)
				{
					win[y] = 1;
				}
			}
		}
	};
	calcWin();
	while (m--)
	{
		int op, k;
		cin >> op >> k;
		if (op == 1)
		{
			if (lastPos[k] != -1)
			{
				s.erase({-lastPos[k], k});
			}
			lastPos[k] = n++;
			s.insert({-lastPos[k], k});
			calcWin();
		}
		else
		{
			assert(win[k] != -1);
			cout << (win[k] == 1 ? "Grammy\n" : "Alice\n");
		}
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Runtime Error

input:

3
3
1 2 3
1
10
4
5 5 5 5

output:


result: