QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#397807#6394. Turn on the Lightkinoko777WA 1ms3712kbC++201.9kb2024-04-24 17:08:332024-04-24 17:08:33

Judging History

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

  • [2024-04-24 17:08:33]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3712kb
  • [2024-04-24 17:08:33]
  • 提交

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

signed main()
{
 	IOS;
	int tt = 1;
	//cin >> tt;
	pre_work();
	while(tt --)
	{
		solve();
	}
	return 0;
}

详细

Test #1:

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

input:

3
1
2
2

output:

? 1
? 2
? 3
! 3

result:

ok Correct position at 3

Test #2:

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

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

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

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

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

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

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

input:

3
1
1

output:

? 1
? 2
! 2

result:

ok Correct position at 2

Test #10:

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

input:

2
1
1

output:

? 1
? 2
! 2

result:

ok Correct position at 2

Test #11:

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

input:

1
0

output:

? 1
! 1

result:

ok Correct position at 1

Test #12:

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

input:

1000000
1
2
3
4
5
6
7
8
9
10
11
10

output:

? 1
? 2
? 3
? 4
? 5
? 6
? 7
? 8
? 9
? 10
? 500005
? 750003
! 750003

result:

wrong answer Wrong answer, more than 1 possible light!