QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#397824 | #6394. Turn on the Light | kinoko777 | WA | 1ms | 3704kb | C++20 | 1.9kb | 2024-04-24 17:21:02 | 2024-04-24 17:21:02 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
// #define int long long
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> p11;
typedef pair<string, int> ps1;
typedef pair<ll, ll> p1111;
#define vv vector
#define pb emplace_back
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fi first
#define se second
// #define endl '\n'
// #define Endl '\n'
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define per(a, b, c) for(int a = b; a <= c; a ++)
#define rep(a, b, c) for(int a = b; a >= c; a --)
#define aper(A) for(auto i : A) cout << i << ' ';cout << '\n'
#define lowbit(x) ((x) & (-x))
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define PAI acos(-1)
using ll = long long;
#define double long double
void umin(int &x,int y){if(x>y)x=y;}
void umax(int &x,int y){if(x<y)x=y;}
const int mod = 1e9 + 7;
void add(int &x, int y){x = (x + y) % mod;}
void pre_work(){}
int ask(int x)
{
cout << "? " << x << endl;
int a;
cin >> a;
return a;
}
void pri(int x)
{
cout << "! " << x << endl;
}
void solve()
{
int n;
cin >> n;
int pre = 0;
for(int i = 1; i <= 15; i ++)
{
int now = ask(i);
if(now == pre)
{
pri(i);
return;
}
pre = now;
}
int l = pre, r = n;
while(l < r)
{
int mid = l + r + 1 >> 1;
int x = ask(mid);
if(x == pre)
{
pri(mid);
return;
}
else if(x > pre)
{
l = mid + 1;
}
else
{
r = mid - 1;
}
pre = x;
}
}
signed main()
{
IOS;
int tt = 1;
//cin >> tt;
pre_work();
while(tt --)
{
solve();
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3644kb
input:
3 1 2 2
output:
? 1 ? 2 ? 3 ! 3
result:
ok Correct position at 3
Test #2:
score: 0
Accepted
time: 1ms
memory: 3656kb
input:
10 1 2 3 4 5 6 7 8 8
output:
? 1 ? 2 ? 3 ? 4 ? 5 ? 6 ? 7 ? 8 ? 9 ! 9
result:
ok Correct position at 9
Test #3:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
9 1 2 3 4 5 6 7 7
output:
? 1 ? 2 ? 3 ? 4 ? 5 ? 6 ? 7 ? 8 ! 8
result:
ok Correct position at 8
Test #4:
score: 0
Accepted
time: 0ms
memory: 3696kb
input:
8 1 2 3 4 5 6 6
output:
? 1 ? 2 ? 3 ? 4 ? 5 ? 6 ? 7 ! 7
result:
ok Correct position at 7
Test #5:
score: 0
Accepted
time: 1ms
memory: 3644kb
input:
7 1 2 3 4 5 5
output:
? 1 ? 2 ? 3 ? 4 ? 5 ? 6 ! 6
result:
ok Correct position at 6
Test #6:
score: 0
Accepted
time: 0ms
memory: 3704kb
input:
6 1 2 3 4 5 5
output:
? 1 ? 2 ? 3 ? 4 ? 5 ? 6 ! 6
result:
ok Correct position at 6
Test #7:
score: 0
Accepted
time: 1ms
memory: 3652kb
input:
5 1 2 3 3
output:
? 1 ? 2 ? 3 ? 4 ! 4
result:
ok Correct position at 4
Test #8:
score: 0
Accepted
time: 1ms
memory: 3576kb
input:
4 1 2 3 3
output:
? 1 ? 2 ? 3 ? 4 ! 4
result:
ok Correct position at 4
Test #9:
score: 0
Accepted
time: 0ms
memory: 3644kb
input:
3 1 1
output:
? 1 ? 2 ! 2
result:
ok Correct position at 2
Test #10:
score: 0
Accepted
time: 1ms
memory: 3648kb
input:
2 1 1
output:
? 1 ? 2 ! 2
result:
ok Correct position at 2
Test #11:
score: 0
Accepted
time: 1ms
memory: 3584kb
input:
1 0
output:
? 1 ! 1
result:
ok Correct position at 1
Test #12:
score: -100
Wrong Answer
time: 1ms
memory: 3704kb
input:
1000000 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 15 14 13 12 11 10 9 8 7 6 5 4 3 4 3 2 1 2
output:
? 1 ? 2 ? 3 ? 4 ? 5 ? 6 ? 7 ? 8 ? 9 ? 10 ? 11 ? 12 ? 13 ? 14 ? 15 ? 500008 ? 750005 ? 625007 ? 562508 ? 531258 ? 515633 ? 507821 ? 503915 ? 501962 ? 500985 ? 500497 ? 500253 ? 500131 ? 500070 ? 500039 ? 500055 ? 500047 ? 500043 ? 500041
result:
wrong answer format Unexpected end of file - token expected