QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#397828#6394. Turn on the Lightkinoko777WA 1ms3708kbC++201.9kb2024-04-24 17:22:262024-04-24 17:22:27

Judging History

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

  • [2024-04-24 17:22:27]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3708kb
  • [2024-04-24 17:22:26]
  • 提交

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 = 16, 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: 3568kb

input:

3
1
2
2

output:

? 1
? 2
? 3
! 3

result:

ok Correct position at 3

Test #2:

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

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

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

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

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

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

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

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

input:

2
1
1

output:

? 1
? 2
! 2

result:

ok Correct position at 2

Test #11:

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

input:

1
0

output:

? 1
! 1

result:

ok Correct position at 1

Test #12:

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

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
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
? 500042
! 500042

result:

ok Correct position at 500042

Test #13:

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

input:

999999
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
14
13
12
11
10
9
8
7
6
5
4
3
2
1
2
1
0
1
2
3

output:

? 1
? 2
? 3
? 4
? 5
? 6
? 7
? 8
? 9
? 10
? 11
? 12
? 13
? 14
? 15
? 500008
? 250012
? 125014
? 62515
? 31265
? 15640
? 7828
? 3922
? 1969
? 992
? 504
? 260
? 138
? 77
? 46
? 62
? 54
? 50
? 52
? 53

result:

wrong answer format  Unexpected end of file - token expected