QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#885635#9734. Identify ChordAir_Color5Compile Error//C++141.2kb2025-02-06 16:47:412025-02-06 16:47:43

Judging History

This is the latest submission verdict.

  • [2025-02-06 16:47:43]
  • Judged
  • [2025-02-06 16:47:41]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;
int n;
int Query(int a, int b) {
	if (a == b) {
		return 0;
	}
	printf("? %d %d\n", a, b);
	fflush(stdout);
	int v;
	scanf("%d", &v);
	return v;
}
inline int Prev(int a) {
	return (a == 1 ? n : a - 1);
}
inline int Next(int a) {
	return (a == n ? 1 : a + 1);
}
inline int Walk(int a, long long b) {
	return (((long long)a + b) % n + n - 1) % n + 1;
}
random_device rd;
mt19937 mt(rd());
void Solve() {
	scanf("%d", &n);
	int a, b, DIS;
	a = 1, b = 1 + n / 2;
	if (Query(a, b) == n / 2 and n % 2 == 1) {
		b++;
	}
	while ((DIS = Query(a, b)) == n / 2) {
		Walk(a + 1), Walk(b + 1);
	}
	int d;
	if (Query(Prev(a), b) == DIS - 1) {
		d = -1;
	}
	else {
		d = 1;
	}
	for (int i = __lg(n) - 1; i >= 0; i--) {
		int A = Walk(a, d * (1 << i));
		int D = Query(A, b);
		if ((1ll << i) + D == DIS) {
			DIS = D;
			a = A;
		}
	}
	if (Query(a, Walk(b, DIS - 1)) == 1) {
		b = Walk(b, DIS - 1);
	}
	else {
		b = Walk(b, 1 - DIS);
	}
	printf("! %d %d\n", a, b);
	fflush(stdout);
	int res;
	scanf("%d", &res);
	if (res == -1) {
		exit(0);
	}
}
signed main() {
	int t;
	scanf("%d", &t);
	while (t--) {
		Solve();
	}
	return 0;
}

Details

answer.code: In function ‘void Solve()’:
answer.code:33:21: error: too few arguments to function ‘int Walk(int, long long int)’
   33 |                 Walk(a + 1), Walk(b + 1);
      |                 ~~~~^~~~~~~
answer.code:20:12: note: declared here
   20 | inline int Walk(int a, long long b) {
      |            ^~~~
answer.code:33:34: error: too few arguments to function ‘int Walk(int, long long int)’
   33 |                 Walk(a + 1), Walk(b + 1);
      |                              ~~~~^~~~~~~
answer.code:20:12: note: declared here
   20 | inline int Walk(int a, long long b) {
      |            ^~~~
answer.code: In function ‘int Query(int, int)’:
answer.code:11:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   11 |         scanf("%d", &v);
      |         ~~~~~^~~~~~~~~~
answer.code: In function ‘void Solve()’:
answer.code:26:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   26 |         scanf("%d", &n);
      |         ~~~~~^~~~~~~~~~
answer.code:59:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   59 |         scanf("%d", &res);
      |         ~~~~~^~~~~~~~~~~~
answer.code: In function ‘int main()’:
answer.code:66:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   66 |         scanf("%d", &t);
      |         ~~~~~^~~~~~~~~~