QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#645934#6303. InversionTerac#WA 30ms3840kbC++142.6kb2024-10-16 20:30:582024-10-16 20:31:00

Judging History

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

  • [2024-10-16 20:31:00]
  • 评测
  • 测评结果:WA
  • 用时:30ms
  • 内存:3840kb
  • [2024-10-16 20:30:58]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define ll long long
namespace IO {
//	#if ONLINE_JUDGE
//	#define getc() (IS == IT && (IT = (IS = ibuf) + fread(ibuf, 1, IL, stdin), IS == IT) ? EOF : *IS++)
//	#else
	#define getc() getchar()
//	#endif
	const int IL = 1 << 21, OL = 1 << 21;
	int olen = 0;
	char ibuf[IL], *IS = ibuf, *IT = ibuf, obuf[OL];
	inline int read() {
		register char ch = getc(); register int x = 0, f = 1;
		while(!isdigit(ch)) { if(ch == '-') f = -1; ch = getc(); }
		while(isdigit(ch)) x = x * 10 + ch - 48, ch = getc();
		return x * f;
	}
	inline double readdb() {
		register char ch = getc(); register double x = 0, f = 1;
		while(!isdigit(ch)) { if(ch == '-') f = -1; ch = getc(); }
		while(isdigit(ch)) x = x * 10 + ch - 48, ch = getc();
		if(ch == '.') {
			register double b = 0.1;
			ch = getc();
			while(isdigit(ch)) x += (ch - 48) * b, b *= 0.1, ch = getc();
		}
		return x * f;
	}
	inline int readstr(char *s) {
		register char ch = getc(); register int len = 0;
		while(!isalpha(ch)) ch = getc();
		while(isalpha(ch)) s[++len] = ch, ch = getc();
		return len;
	}
	inline void flush() { fwrite(obuf, 1, olen, stdout); olen = 0; }
	inline void putc(register char ch) { obuf[olen++] = ch; }
	template<class T>
	inline void write(register T x) {
		if(x < 0) obuf[olen++] = '-', x = -x;
		if(x > 9) write(x / 10);
		obuf[olen++] = x % 10 + 48;
	}
} using namespace IO;
const int N = 2e3 + 10;
int cnt = 0;
bool cmp(int x, int y) {
	if(x > y) swap(x, y);
	if(x == y - 1) {
		cnt++;
		printf("? %d %d\n", x, y);
		fflush(stdout);
		return read();
		return 0;
	}
	cnt+=2;
	int res = 0;
//	printf("? %d %d\n", x, y);
//	fflush(stdout);
//	res ^= read();
	printf("? %d %d\n", x + 1, y);
	fflush(stdout);
	res ^= read();
	printf("? %d %d\n", x, y - 1);
	fflush(stdout);
	res ^= read();
//	printf("? %d %d\n", x + 1, y - 1);
//	fflush(stdout);
//	res ^= read();
	return res;
}
int p[N], tmp[N];
void solve(int l, int r) {
	if(l == r) return;
	int mid = l + r >> 1;
	solve(l, mid);
	solve(mid + 1, r);
	int i = l, j = mid + 1, k = i;
	while(i <= mid && j <= r) {
		if(cmp(p[i], p[j])) tmp[k++] = p[j++];
		else tmp[k++] = p[i++];
	}
	while(i <= mid) tmp[k++] = p[i++];
	while(j <= r) tmp[k++] = p[j++];
	for(i = l; i <= r; i++) p[i] = tmp[i];
}
int id[N];
int main() {
	int n;
	n = read();
	iota(p + 1, p + 1 + n, 1);
	solve(1, n);
	for(int i = 1; i <= n; i++)
		id[p[i]] = i;
	printf("! ");
	for(int i = 1; i <= n; i++)
		printf("%d ", id[i]);
	fflush(stdout);
//	cout << cnt << endl;
	return 0;
}

詳細信息

Test #1:

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

input:

3
0
1
0

output:

? 1 2
? 2 3
? 1 2
! 2 3 1 

result:

ok OK, guesses=3

Test #2:

score: -100
Wrong Answer
time: 30ms
memory: 3784kb

input:

1993
0
0
0
0
0
0
0
1
0
1
0
1
0
1
0
1
0
0
0
0
1
1
0
0
0
1
0
0
1
0
0
0
1
0
0
1
0
1
1
0
1
0
0
0
0
0
1
0
1
1
1
1
1
1
0
0
1
0
1
0
1
1
1
0
1
1
0
0
1
0
0
0
0
0
1
0
1
0
1
0
0
0
1
0
0
1
1
1
1
0
1
1
0
0
0
1
1
0
0
1
0
0
0
0
1
1
1
1
0
0
0
1
1
1
0
1
1
1
1
1
1
0
1
1
0
0
1
1
0
0
1
0
0
1
0
0
1
1
0
0
0
1
0
1
0
0
1
0...

output:

? 1 2
? 3 4
? 2 3
? 1 2
? 2 3
? 5 6
? 7 8
? 6 7
? 5 6
? 6 8
? 5 7
? 2 7
? 1 6
? 2 8
? 1 7
? 2 5
? 1 4
? 2 6
? 1 5
? 3 6
? 2 5
? 9 10
? 11 12
? 10 11
? 10 11
? 9 10
? 10 12
? 9 11
? 13 14
? 15 16
? 14 15
? 14 15
? 13 14
? 14 16
? 13 15
? 11 14
? 10 13
? 11 15
? 10 14
? 12 15
? 11 14
? 12 13
? 11 12
?...

result:

wrong answer Wa.