QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#105560#6394. Turn on the Lightwoyouxiangbaile#WA 4ms3436kbC++141.4kb2023-05-14 13:21:582023-05-14 13:22:00

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-14 13:22:00]
  • 评测
  • 测评结果:WA
  • 用时:4ms
  • 内存:3436kb
  • [2023-05-14 13:21:58]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define rep(i, d, u) for(int i = d; i <= u; ++i)
#define dep(i, u, d) for(int i = u; i >= d; --i)
#define cep(n) while(n--)
#define gep(i, a) for(int i = firs[a]; i; i = neig[i])
int ured() {
	int re = 0;
	char ch;
	do {
		ch = getchar();
	} while('9' < ch || ch < '0');
	do {
		re = re * 10 + (ch ^ '0');
	} while('0' <= (ch = getchar()) && ch <= '9');
	return re;
}
void uwit(int da) {
	int ch[21], cn = 0;
	do {
		ch[++cn] = da - da / 10 * 10;
	} while(da /= 10);
	do {
		putchar('0' ^ ch[cn]);
	} while(--cn);
}
const int _maxn = 1000011;
int n, efle, efri, efmi, efan, lans, rans, tans, matp;
vector<int> rest, cpys;
int quer(int at) {
	putchar('?'), putchar(' '), uwit(at), putchar('\n'), fflush(stdout);
	return ured();
}
int main() {
	n = ured();
	rep(i, 1, n) {
		rest . push_back(i);
	}
	while(rest . size()) {
		if((lans = quer(rest[0])) == tans) {
			putchar('!'), putchar(' '), uwit(rest[0]), putchar('\n'), fflush(stdout);
			return 0;
		}
		if((rans = quer(rest[matp = rest . size() >> 1])) == lans) {
			putchar('!'), putchar(' '), uwit(rest[0]), putchar('\n'), fflush(stdout);
			return 0;
		}
		cpys = rest, rest . clear();
		if(rans == tans) {
			rep(i, 1, matp - 1) {
				rest . push_back(cpys[i]);
			}
		} else {
			rep(i, matp + 1, cpys . size() - 1) {
				rest . push_back(cpys[i]);
			}
		}
		tans = rans;
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3
1
2
2

output:

? 1
? 2
? 3
! 3

result:

ok Correct position at 3

Test #2:

score: 0
Accepted
time: 4ms
memory: 3260kb

input:

10
1
0
1
0
0

output:

? 1
? 6
? 2
? 4
? 3
! 3

result:

ok Correct position at 3

Test #3:

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

input:

9
1
2
3
2
2

output:

? 1
? 5
? 6
? 8
? 7
! 7

result:

ok Correct position at 7

Test #4:

score: -100
Wrong Answer
time: 2ms
memory: 3268kb

input:

8
1
0
1
1

output:

? 1
? 5
? 2
? 3
! 2

result:

wrong answer Wrong favorite light!