QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#374688#8311. Game on SequencePetroTarnavskyi#AC ✓179ms4856kbC++201.4kb2024-04-02 17:04:202024-04-02 17:04:21

Judging History

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

  • [2024-04-02 17:04:21]
  • 评测
  • 测评结果:AC
  • 用时:179ms
  • 内存:4856kb
  • [2024-04-02 17:04:20]
  • 提交

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;
	VI a(n);
	FOR(i, 0, n)
	{
		cin >> a[i];
		lastPos[a[i]] = 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)
			{
				win[x ^ (1 << j)] = 1;
			}
		}
	};
	calcWin();
	while (m--)
	{
		int op, k;
		cin >> op >> k;
		if (op == 1)
		{
			if (lastPos[k] != -1)
			{
				s.erase({-lastPos[k], k});
			}
			a.PB(k);
			lastPos[k] = n++;
			s.insert({-lastPos[k], k});
			calcWin();
		}
		else
		{
			k--;
			int x = a[k];
			assert(win[x] != -1);
			cout << (win[x] == 1 || k != lastPos[x] ? "Grammy\n" : "Alice\n");
		}
	}
	return 0;
}

这程序好像有点Bug,我给组数据试试?

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3636kb

input:

5 5
1 2 3 4 5
1 6
2 5
1 7
2 5
2 1

output:

Alice
Grammy
Alice

result:

ok 3 lines

Test #2:

score: 0
Accepted
time: 0ms
memory: 3548kb

input:

10 10
12 114 132 7 133 53 128 159 34 92
2 5
1 254
2 3
2 11
1 92
2 11
1 33
1 230
1 181
2 11

output:

Alice
Grammy
Alice
Alice
Alice

result:

ok 5 lines

Test #3:

score: 0
Accepted
time: 0ms
memory: 3612kb

input:

100 100
57 58 24 217 80 0 241 175 19 138 231 17 8 19 22 100 133 205 178 67 55 92 127 254 156 89 87 22 136 208 168 195 164 194 243 110 234 164 78 55 43 223 227 112 137 78 111 31 253 194 196 128 210 129 71 129 40 195 114 69 114 52 83 162 248 117 12 162 86 155 81 6 251 174 237 190 171 44 61 114 254 131...

output:

Grammy
Grammy
Alice
Alice
Grammy
Grammy
Alice
Alice
Grammy
Alice
Grammy
Grammy
Grammy
Alice
Grammy
Alice
Alice
Alice
Alice
Grammy
Alice
Grammy
Alice
Grammy
Alice
Grammy
Grammy
Alice
Grammy
Grammy
Alice
Alice
Grammy
Grammy
Grammy
Alice
Alice
Grammy
Alice
Grammy
Grammy
Grammy
Grammy
Alice
Grammy
Grammy

result:

ok 46 lines

Test #4:

score: 0
Accepted
time: 1ms
memory: 3540kb

input:

200 200
56 236 246 71 3 39 174 73 229 150 161 184 163 240 96 38 57 65 238 184 84 105 70 169 217 155 211 197 92 224 245 239 170 146 131 155 63 225 68 84 208 81 117 55 195 58 70 118 178 71 93 215 236 248 81 51 244 32 48 247 0 103 249 166 123 200 35 84 131 20 21 45 108 110 171 236 59 206 184 100 43 126...

output:

Grammy
Alice
Alice
Grammy
Alice
Grammy
Grammy
Grammy
Grammy
Grammy
Grammy
Grammy
Alice
Grammy
Alice
Alice
Grammy
Grammy
Alice
Alice
Grammy
Grammy
Alice
Grammy
Alice
Grammy
Grammy
Grammy
Grammy
Grammy
Grammy
Grammy
Grammy
Alice
Alice
Alice
Grammy
Grammy
Grammy
Grammy
Grammy
Grammy
Grammy
Grammy
Alice...

result:

ok 101 lines

Test #5:

score: 0
Accepted
time: 1ms
memory: 3620kb

input:

300 300
54 158 213 181 183 78 108 227 182 162 92 95 62 204 169 232 236 181 43 45 114 118 12 84 21 222 78 116 48 240 67 26 175 97 19 200 149 30 57 113 118 196 6 255 253 38 29 206 104 203 245 46 7 110 91 228 192 124 237 169 142 153 159 170 253 27 58 6 176 141 216 84 220 46 106 26 202 112 50 87 89 121 ...

output:

Grammy
Grammy
Grammy
Alice
Alice
Alice
Alice
Grammy
Alice
Grammy
Alice
Grammy
Grammy
Grammy
Alice
Grammy
Grammy
Grammy
Alice
Grammy
Alice
Grammy
Grammy
Grammy
Grammy
Grammy
Grammy
Grammy
Grammy
Grammy
Grammy
Alice
Grammy
Alice
Grammy
Grammy
Grammy
Grammy
Grammy
Grammy
Alice
Grammy
Alice
Alice
Grammy...

result:

ok 155 lines

Test #6:

score: 0
Accepted
time: 1ms
memory: 3616kb

input:

1000 1000
88 174 158 173 160 193 246 152 104 28 88 9 127 191 219 89 232 253 13 117 89 254 110 96 189 62 243 175 178 12 132 11 12 12 126 179 80 182 49 247 58 213 98 190 55 8 203 1 235 68 151 77 173 80 230 69 6 71 79 30 54 26 89 34 175 12 0 46 152 52 55 51 75 254 96 184 215 170 213 86 126 204 99 59 56...

output:

Grammy
Grammy
Grammy
Grammy
Grammy
Grammy
Grammy
Alice
Grammy
Alice
Grammy
Grammy
Alice
Alice
Grammy
Grammy
Grammy
Alice
Alice
Grammy
Grammy
Grammy
Grammy
Grammy
Grammy
Alice
Grammy
Grammy
Grammy
Grammy
Alice
Grammy
Grammy
Alice
Alice
Grammy
Grammy
Grammy
Grammy
Grammy
Grammy
Grammy
Alice
Alice
Alic...

result:

ok 506 lines

Test #7:

score: 0
Accepted
time: 19ms
memory: 3668kb

input:

20000 20000
57 18 228 217 20 96 113 67 96 16 189 26 199 140 91 192 101 209 147 110 74 241 221 175 252 145 106 227 242 107 155 189 26 205 135 197 84 25 122 215 244 67 112 163 68 86 158 43 255 239 234 71 216 192 110 36 241 15 249 193 100 52 141 112 190 30 226 91 126 207 226 253 155 219 43 165 251 237 ...

output:

Grammy
Grammy
Grammy
Alice
Alice
Grammy
Grammy
Grammy
Grammy
Alice
Grammy
Grammy
Grammy
Grammy
Grammy
Grammy
Grammy
Grammy
Grammy
Grammy
Grammy
Alice
Grammy
Grammy
Grammy
Grammy
Grammy
Grammy
Grammy
Grammy
Grammy
Grammy
Grammy
Grammy
Alice
Grammy
Grammy
Grammy
Grammy
Grammy
Grammy
Grammy
Grammy
Gram...

result:

ok 9915 lines

Test #8:

score: 0
Accepted
time: 178ms
memory: 4684kb

input:

200000 200000
38 224 25 219 240 25 127 46 150 104 78 69 165 37 77 64 192 217 151 179 28 196 29 40 3 88 34 155 81 187 189 252 250 73 90 176 130 16 57 17 131 83 238 233 43 8 223 251 187 90 202 122 9 39 60 144 255 130 26 217 26 50 28 229 235 50 77 185 153 47 141 78 94 13 15 17 6 98 219 98 115 250 77 21...

output:

Grammy
Grammy
Grammy
Grammy
Grammy
Grammy
Alice
Grammy
Grammy
Grammy
Alice
Grammy
Grammy
Alice
Grammy
Grammy
Grammy
Grammy
Grammy
Grammy
Grammy
Grammy
Grammy
Grammy
Alice
Grammy
Grammy
Grammy
Grammy
Alice
Grammy
Grammy
Alice
Alice
Grammy
Alice
Alice
Grammy
Grammy
Grammy
Grammy
Grammy
Grammy
Grammy
G...

result:

ok 99929 lines

Test #9:

score: 0
Accepted
time: 170ms
memory: 3876kb

input:

1 200000
178
2 1
2 1
1 43
2 2
2 1
1 210
2 1
1 110
2 3
1 37
1 170
2 1
1 161
2 5
1 243
2 4
2 7
2 1
1 245
2 4
1 254
2 7
2 3
2 8
1 24
1 195
1 74
2 10
2 10
2 10
1 104
1 122
2 9
1 206
2 16
2 16
1 38
1 111
1 192
2 13
2 16
2 11
1 53
2 19
2 16
1 23
1 60
2 16
1 159
2 20
2 14
2 3
1 153
2 4
2 5
2 9
2 18
1 202
2...

output:

Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Grammy
Grammy
Alice
Alice
Alice
Alice
Alice
Grammy
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Grammy
Alice
Grammy
A...

result:

ok 100023 lines

Test #10:

score: 0
Accepted
time: 6ms
memory: 3960kb

input:

200000 1
61 83 233 161 113 83 59 13 165 46 90 65 231 185 141 221 88 1 112 246 174 195 114 148 179 242 86 52 195 52 182 70 82 102 123 176 100 20 102 73 19 1 139 95 13 165 208 50 20 170 115 118 124 111 129 213 176 133 96 107 173 52 70 72 132 247 191 242 221 252 43 224 111 165 61 0 137 9 125 49 140 115...

output:

Grammy

result:

ok single line: 'Grammy'

Test #11:

score: 0
Accepted
time: 173ms
memory: 4000kb

input:

100000 200000
189 101 194 145 97 254 75 51 137 14 5 232 78 247 155 244 16 253 64 188 242 199 40 73 92 226 12 204 121 62 170 20 183 175 67 25 73 109 28 117 168 148 253 230 14 165 181 206 249 4 147 179 174 119 239 191 180 173 159 64 85 181 130 41 32 131 249 144 106 110 104 46 200 181 186 226 150 245 2...

output:

Grammy
Grammy
Grammy
Alice
Grammy
Alice
Grammy
Grammy
Grammy
Alice
Grammy
Alice
Grammy
Grammy
Alice
Grammy
Grammy
Grammy
Alice
Grammy
Alice
Grammy
Grammy
Alice
Alice
Grammy
Grammy
Grammy
Grammy
Grammy
Grammy
Alice
Alice
Grammy
Grammy
Grammy
Grammy
Grammy
Grammy
Grammy
Grammy
Grammy
Grammy
Grammy
Ali...

result:

ok 100006 lines

Test #12:

score: 0
Accepted
time: 171ms
memory: 4856kb

input:

200000 200000
109 183 127 127 150 131 50 33 108 121 94 117 193 9 214 187 138 101 212 57 97 6 115 185 6 37 52 6 218 67 122 115 98 161 14 83 202 201 155 130 95 3 51 218 20 225 200 191 254 180 180 148 216 19 50 68 128 91 226 186 120 42 73 104 102 228 78 196 148 46 191 199 112 118 202 108 13 104 132 55 ...

output:

Alice
Alice
Grammy
Grammy
Grammy
Grammy
Grammy
Grammy
Alice
Grammy
Alice
Grammy
Grammy
Alice
Alice
Alice
Alice
Grammy
Grammy
Grammy
Grammy
Alice
Grammy
Alice
Grammy
Grammy
Grammy
Grammy
Grammy
Grammy
Grammy
Grammy
Alice
Alice
Grammy
Grammy
Grammy
Grammy
Grammy
Grammy
Grammy
Grammy
Grammy
Grammy
Alic...

result:

ok 100100 lines

Test #13:

score: 0
Accepted
time: 171ms
memory: 4856kb

input:

200000 200000
205 228 201 164 156 188 1 149 120 47 53 52 91 74 105 168 244 236 150 42 38 72 41 136 135 101 129 163 226 161 116 241 181 42 202 252 180 132 193 224 68 6 136 209 1 92 196 147 56 6 13 0 109 216 114 134 215 120 241 166 223 228 0 118 165 233 7 32 123 172 227 97 103 37 101 11 165 159 209 13...

output:

Grammy
Alice
Grammy
Grammy
Grammy
Alice
Grammy
Grammy
Grammy
Alice
Grammy
Alice
Grammy
Grammy
Grammy
Grammy
Grammy
Alice
Grammy
Grammy
Grammy
Alice
Grammy
Grammy
Grammy
Grammy
Grammy
Grammy
Grammy
Grammy
Grammy
Grammy
Alice
Grammy
Grammy
Alice
Grammy
Grammy
Grammy
Grammy
Grammy
Grammy
Alice
Grammy
G...

result:

ok 100026 lines

Test #14:

score: 0
Accepted
time: 179ms
memory: 4696kb

input:

200000 200000
45 16 19 202 162 245 209 9 131 230 13 244 245 139 252 149 95 114 88 27 234 137 222 87 8 166 206 64 234 255 110 111 8 178 135 164 158 62 230 63 41 8 221 199 237 216 191 103 114 89 103 108 3 156 178 200 46 149 0 146 70 157 183 132 228 238 192 124 98 42 8 251 95 213 0 169 62 214 30 207 16...

output:

Grammy
Grammy
Grammy
Alice
Grammy
Grammy
Grammy
Grammy
Alice
Alice
Grammy
Alice
Alice
Alice
Alice
Grammy
Alice
Grammy
Grammy
Grammy
Grammy
Alice
Alice
Alice
Grammy
Grammy
Grammy
Grammy
Grammy
Grammy
Alice
Alice
Grammy
Grammy
Grammy
Grammy
Grammy
Grammy
Grammy
Alice
Alice
Grammy
Grammy
Grammy
Grammy
...

result:

ok 100127 lines

Extra Test:

score: 0
Extra Test Passed