QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#387261#6394. Turn on the Light1ockhart#Compile Error//C++201.1kb2024-04-12 11:16:252024-04-12 11:16:25

Judging History

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

  • [2024-04-12 11:16:25]
  • 评测
  • [2024-04-12 11:16:25]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("avx2")

using ll = long long;
//using i128 = __int128_t;
//#define endl "\n"
#define int long long
#define db cout << "db" << endl;
#define x first
#define y second
typedef pair<int, int> PII;
const int N = 5e5 + 10;
ll inf = 2e18;
void solve() {
	int n;
	cin >> n;
	int l = 1, r = n, cnt = 0;
	while (l <= r) {
		if (l == r) {
			cout << "! " << l << endl;
			return;
		}
		int mid = (l + r + 1) >> 1, x1, x2;
		bool f1 = 0, f2 = 0;
		cout << "? " << l << endl; cnt++;
		cin >> x1;
		if (x1 > prex1)
		if (cnt % 2 != x1 % 2) {
			cout << "! " << l << endl;
			return;
		}
		cout << "? " << mid << endl; cnt++;
		cin >> x2;
		if (cnt % 2 != x2 % 2) {
			cout << "! " << mid << endl;
			return;
		}
		prex1 = x1; prex2 = x2;
		if (x2 > x1) l = mid + 1;
		else {
			r = mid - 1;
			l++;
		}
	}	
}
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int q = 1;
    //cin >> q;
    while (q --) {
        solve();
    }
    return 0;
} 

Details

answer.code: In function ‘void solve()’:
answer.code:30:26: error: ‘prex1’ was not declared in this scope
   30 |                 if (x1 > prex1)
      |                          ^~~~~
answer.code:41:17: error: ‘prex1’ was not declared in this scope
   41 |                 prex1 = x1; prex2 = x2;
      |                 ^~~~~
answer.code:41:29: error: ‘prex2’ was not declared in this scope
   41 |                 prex1 = x1; prex2 = x2;
      |                             ^~~~~