QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#378389#6394. Turn on the LightRainbowX#WA 1ms3684kbC++201.8kb2024-04-06 12:25:362024-04-06 12:25:44

Judging History

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

  • [2024-04-06 12:25:44]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3684kb
  • [2024-04-06 12:25:36]
  • 提交

answer

#pragma GCC optimize(3)
#include <bits/stdc++.h>

#define f(i, n, m) for (long long i = n; i <= m; ++i)
#define unf(i, n, m) for (long long i = n; i >= m; --i)
#define kong NULL
#define debug cout << "sss" << endl;

using ll = long long;
using ull = unsigned long long;
using point_t = double; // 计算几何的默认类型

const double e = exp(1.0);
const double pi = acos(-1.0);
constexpr ll inf = 0x3f3f3f3f3f3f3f3f;
constexpr ll maxx = 0x3f3f3f3f3f3f3f3f;
constexpr ll minn = 0xc0c0c0c0c0c0c0c0;

// #define endl '\n'
constexpr char blank = ' ';
constexpr ll mod = (ll)998244353;
constexpr size_t N = (size_t)1e6 + 6;

#ifdef _DEBUG
#define Crash(...) (__debugbreak(), 0)
#define Debug(...) (__debugbreak(), 0)
#else
#define Crash(...) (exit(-1), 0)
#define Debug(...) ((void)0)
#endif // _DEBUG

#define ensure(expression) (void)(!!(expression) || Crash())

inline void setaccuracy(const std::streamsize &accuracy)
{
  std::cout << std::fixed << std::setprecision(accuracy);
}

#define int long long
using namespace std;


void solve()
{
  int n;
  cin>>n;
  int l=1,r=1;
  int jue=0;
  f(i,1,min(n,(int)20)){
    cout<<"? "<<i<<endl;
    int a;
    cin>>a;
    if(a==jue){
      cout<<"! "<<i<<endl;
      return;
    }
    jue=a;
  }
  l=21;
  while(l<=r){
    int mid=l+r>>1;
    cout<<"? "<<mid<<endl;
    int a;
    cin>>a;
    if(a>jue){
      l=mid+1;
    }
    else if(a<jue){
      r=mid-1;
    }
    else {
      cout<<"! "<<mid<<endl;
      return;
    }

  }


  // std::cout<< minn<<endl;
}

signed main()
{
  // ios::sync_with_stdio(false);
  // std::cin.tie(nullptr);
  // std::cout.tie(nullptr);
  int T = 1;
  // cin >> T;
  // scanf(" %d", &T);
  // std::cin >> T;
  // for (int q = 1; q <= T; q++) {
  // while (T--) {
  solve();
  // }

  return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3528kb

input:

3
1
2
2

output:

? 1
? 2
? 3
! 3

result:

ok Correct position at 3

Test #2:

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

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

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

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

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

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

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

input:

4
1
2
3
3

output:

? 1
? 2
? 3
? 4
! 4

result:

ok Correct position at 4

Test #9:

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

input:

3
1
1

output:

? 1
? 2
! 2

result:

ok Correct position at 2

Test #10:

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

input:

2
1
1

output:

? 1
? 2
! 2

result:

ok Correct position at 2

Test #11:

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

input:

1
0

output:

? 1
! 1

result:

ok Correct position at 1

Test #12:

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

input:

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

output:

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

result:

wrong answer format  Unexpected end of file - token expected