QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#397809#6394. Turn on the Lightkinoko777WA 1ms3720kbC++201.9kb2024-04-24 17:09:312024-04-24 17:09:31

Judging History

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

  • [2024-04-24 17:09:31]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3720kb
  • [2024-04-24 17:09:31]
  • 提交

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 <= 10; 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;
        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;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3
1
2
2

output:

? 1
? 2
? 3
! 3

result:

ok Correct position at 3

Test #2:

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

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: 3656kb

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: 1ms
memory: 3672kb

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: 0ms
memory: 3712kb

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: 1ms
memory: 3592kb

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: 3672kb

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: 3648kb

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: 3652kb

input:

3
1
1

output:

? 1
? 2
! 2

result:

ok Correct position at 2

Test #10:

score: 0
Accepted
time: 0ms
memory: 3632kb

input:

2
1
1

output:

? 1
? 2
! 2

result:

ok Correct position at 2

Test #11:

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

input:

1
0

output:

? 1
! 1

result:

ok Correct position at 1

Test #12:

score: -100
Wrong Answer
time: 1ms
memory: 3720kb

input:

1000000
1
2
3
4
5
6
7
8
9
10
11
10
11
12
11
12
13
14
15
14
15
16
17
18
17
18
19
20
19

output:

? 1
? 2
? 3
? 4
? 5
? 6
? 7
? 8
? 9
? 10
? 500005
? 750003
? 625004
? 687503
? 718753
? 703128
? 710940
? 714846
? 716799
? 717776
? 717287
? 717531
? 717653
? 717714
? 717745
? 717729
? 717737
? 717741
? 717743

result:

wrong answer format  Unexpected end of file - token expected