QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#603985#7804. Intersegment Activationsurgutti#RE 1ms3720kbC++201.7kb2024-10-01 21:37:032024-10-01 21:37:04

Judging History

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

  • [2024-10-01 21:37:04]
  • 评测
  • 测评结果:RE
  • 用时:1ms
  • 内存:3720kb
  • [2024-10-01 21:37:03]
  • 提交

answer

// Author: Olaf Surgut (surgutti)
// Created on 01-10-2024 15:14:12
#include <bits/stdc++.h>
using namespace std;

#ifdef DEBUG
auto&operator<<(auto&o,pair<auto,auto>p){return o<<"("<<p.first<<", "<<p.second<<")";}
auto operator<<(auto&o,auto x)->decltype(x.end(),o){o<<"{";int i=0;for(auto e:x)o<<","+!i++<<e;return o<<"}";}
#define debug(X...)cerr<<"["#X"]: ",[](auto...$){((cerr<<$<<"; "),...)<<endl;}(X)
#else
#define debug(...){}
#endif

#define st first
#define nd second
#define pb push_bask
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define ROF(i, b, a) for (int i = (b); i >= (a); i--)
#define REP(i, n) for (int i = 0; i < (n); i++)

signed main() {

	int n;
	cin >> n;
	int k;
	cin >> k;

	auto flip = [&](int i, int j) {
		cout << i << ' ' << j << endl;
		cin >> k;

		if (k == n) {
			exit(0);
		}
	};

	FOR(i, 1, n - 1) {
		vector<pair<int, int>> segs;

		FOR(j, i, n)
			segs.emplace_back(i, j);

		int prev = 0;
		int goal = -1;
		bool done = false;

		REP(j, 1 << sz(segs)) {
			int mask = j ^ (j >> 1);
			
			if (prev != mask) {
				int id = __builtin_ctz(mask ^ prev);

				flip(segs[id].st, segs[id].nd);
			}
			
			if (k > i) {
				flip(i + 1, n);
				done = true;
			}

			if (k == i) {
				if (goal == -1) {
					goal = mask;
				}
				else {
					flip(i + 1, n);
					done = true;
				}

				if (k == i && done) {
					goal = mask;
					break;
				}
			}

			prev = mask;
		}

		REP(j, sz(segs)) {
			if (((prev >> j) & 1) != ((goal >> j) & 1)) {
				flip(segs[j].first, segs[j].second);
			}
		}
	}

	flip(n, n);

	assert(false);

	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3568kb

input:

3
0
0
0
1
0
0
0
0
0
1
1
2
3

output:

1 1
1 2
1 1
1 3
1 1
1 2
1 1
1 2
1 3
2 2
2 3
2 2

result:

ok OK, 12 queries

Test #2:

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

input:

1
0
1

output:

1 1

result:

ok OK, 1 queries

Test #3:

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

input:

2
1
2

output:

1 1

result:

ok OK, 1 queries

Test #4:

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

input:

2
0
0
1
0
1
2

output:

1 1
1 2
1 1
1 1
2 2

result:

ok OK, 5 queries

Test #5:

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

input:

2
0
1
0
0
0
1
2

output:

1 1
1 2
1 1
1 1
1 2
2 2

result:

ok OK, 6 queries

Test #6:

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

input:

2
0
0
1
2

output:

1 1
1 2
1 1

result:

ok OK, 3 queries

Test #7:

score: -100
Runtime Error

input:

3
0
0
0
0
2
0
1
0
0
1
2
1

output:

1 1
1 2
1 1
1 3
2 3
1 1
1 1
2 2
2 3
2 2
3 3

result: