QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#113955#866. Display of SpringsHongzyAC ✓73ms3596kbC++141.6kb2023-06-20 11:05:292023-06-20 11:05:30

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-06-20 11:05:30]
  • 评测
  • 测评结果:AC
  • 用时:73ms
  • 内存:3596kb
  • [2023-06-20 11:05:29]
  • 提交

answer

#include <bits/stdc++.h>
#define LOG(FMT...) fprintf(stderr, FMT);
#define rep(i, j, k) for(int i = j; i <= k; ++ i)
#define per(i, j, k) for(int i = j; i >= k; -- i)
using namespace std;

const int N = 1e5 + 5, M = 100000;

int id[N << 2];
int query(int x, int y, int w) {
  cout << "? " << x-1 << " " << y-1 << " " << w << endl;
  string s;
  cin >> s;
  if(s == "FIRST") return -1;
  if(s == "SECOND") return 1;
  return 0;
}
int Min(int x, int y, int w) {
  if(!x || !y) return x | y;
  return query(x, y, w) == -1 ? x : y;
}
void modify(int u, int l, int r, int cur) {
  if(!id[u]) {
    id[u] = cur;
    return ;
  }
  if(l == r) {
    id[u] = Min(id[u], cur, l);
    return ;
  }
  int mid = (l + r) >> 1;
  if(Min(id[u], cur, mid) == cur)
    swap(id[u], cur);
  
  if(Min(id[u], cur, l) == cur) {
    modify(u << 1, l, mid, cur);
  } else {
    modify(u << 1 | 1, mid + 1, r, cur);
  }
}
int ans;
void solve(int u, int l, int r, int w) {
  ans = Min(ans, id[u], w);
  if(l == r) {
    return ;
  }
  int mid = (l + r) >> 1;
  if(w <= mid) solve(u << 1, l, mid, w);
  else solve(u << 1 | 1, mid + 1, r, w);
}
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> p(n);
  rep(i, 0, n - 1) p[i] = i + 1;
  random_shuffle(p.begin(), p.begin() + n);
  rep(i, 0, n - 1) {
    modify(1, 1, M, p[i]);
  }
  cout << "!" << endl;
  while(1) {
    string s;
    cin >> s;
    if(s == "FINISH")
      break;
    int w;
    cin >> w;
    ans = 0;
    solve(1, 1, M, w);
    cout << "! " << ans-1 << endl;
  }
  return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 2ms
memory: 3432kb

input:

3
SECOND
FIRST
FIRST
SECOND
QUESTION 2
SECOND
QUESTION 6
FIRST
FINISH

output:

? 0 2 50000
? 2 0 1
? 2 1 50000
? 2 1 1
!
? 2 1 2
! 1
? 2 1 6
! 2

result:

ok Correct answer

Test #2:

score: 0
Accepted
time: 4ms
memory: 3444kb

input:

6
FIRST
SECOND
FIRST
SECOND
FIRST
SECOND
FIRST
SECOND
FIRST
SECOND
SECOND
SECOND
FIRST
SECOND
FIRST
SECOND
FIRST
SECOND
FIRST
EQUAL
SECOND
SECOND
SECOND
SECOND
SECOND
SECOND
SECOND
SECOND
SECOND
EQUAL
QUESTION 1
SECOND
SECOND
SECOND
SECOND
EQUAL
QUESTION 2
SECOND
SECOND
SECOND
EQUAL
FIRST
QUESTION 3...

output:

? 4 3 50000
? 4 3 1
? 4 1 50000
? 4 1 1
? 3 1 25000
? 3 1 1
? 4 2 50000
? 4 2 1
? 3 2 25000
? 3 2 1
? 1 2 12500
? 2 1 1
? 4 0 50000
? 4 0 1
? 3 0 25000
? 3 0 1
? 2 0 12500
? 2 0 1
? 1 0 6250
? 1 0 1
? 4 5 50000
? 5 4 1
? 3 4 25000
? 4 3 1
? 2 3 12500
? 3 2 1
? 1 2 6250
? 2 1 1
? 0 1 3125
? 1 0 1
!
?...

result:

ok Correct answer

Test #3:

score: 0
Accepted
time: 16ms
memory: 3596kb

input:

326
FIRST
FIRST
FIRST
FIRST
FIRST
FIRST
FIRST
SECOND
FIRST
SECOND
SECOND
FIRST
FIRST
SECOND
SECOND
FIRST
SECOND
FIRST
FIRST
SECOND
FIRST
FIRST
SECOND
FIRST
SECOND
FIRST
FIRST
FIRST
SECOND
FIRST
SECOND
FIRST
FIRST
SECOND
FIRST
FIRST
SECOND
FIRST
SECOND
FIRST
SECOND
FIRST
FIRST
FIRST
FIRST
FIRST
SECON...

output:

? 110 290 50000
? 110 290 1
? 110 11 50000
? 110 11 1
? 290 11 75000
? 290 11 50001
? 110 69 50000
? 110 69 1
? 110 209 50000
? 110 209 1
? 69 209 25000
? 209 69 1
? 110 142 50000
? 110 142 1
? 209 142 25000
? 142 209 1
? 69 209 37500
? 209 69 25001
? 110 17 50000
? 110 17 1
? 142 17 25000
? 142 17 ...

result:

ok Correct answer

Test #4:

score: 0
Accepted
time: 6ms
memory: 3504kb

input:

19
FIRST
SECOND
SECOND
SECOND
SECOND
SECOND
SECOND
FIRST
FIRST
FIRST
FIRST
FIRST
SECOND
FIRST
SECOND
FIRST
SECOND
FIRST
SECOND
FIRST
SECOND
FIRST
SECOND
FIRST
SECOND
FIRST
FIRST
FIRST
SECOND
FIRST
SECOND
FIRST
SECOND
FIRST
SECOND
FIRST
FIRST
FIRST
SECOND
FIRST
SECOND
FIRST
SECOND
FIRST
SECOND
FIRST
...

output:

? 4 10 50000
? 4 10 1
? 4 11 50000
? 11 4 1
? 10 4 25000
? 4 10 1
? 11 15 50000
? 15 11 1
? 15 14 50000
? 15 14 1
? 11 14 75000
? 11 14 50001
? 15 16 50000
? 16 15 1
? 11 15 75000
? 15 11 50001
? 14 11 87500
? 11 14 75001
? 16 17 50000
? 17 16 1
? 15 16 75000
? 16 15 50001
? 11 15 87500
? 15 11 7500...

result:

ok Correct answer

Test #5:

score: 0
Accepted
time: 73ms
memory: 3572kb

input:

500
FIRST
FIRST
FIRST
FIRST
FIRST
FIRST
SECOND
SECOND
FIRST
FIRST
FIRST
FIRST
FIRST
FIRST
FIRST
FIRST
FIRST
FIRST
SECOND
FIRST
SECOND
FIRST
SECOND
FIRST
SECOND
FIRST
SECOND
FIRST
SECOND
FIRST
SECOND
FIRST
SECOND
FIRST
SECOND
FIRST
SECOND
FIRST
SECOND
FIRST
SECOND
FIRST
SECOND
FIRST
FIRST
FIRST
FIRST...

output:

? 110 290 50000
? 110 290 1
? 110 11 50000
? 110 11 1
? 290 11 75000
? 290 11 50001
? 110 69 50000
? 69 110 1
? 69 209 50000
? 69 209 1
? 290 209 75000
? 290 209 50001
? 11 209 87500
? 11 209 75001
? 69 468 50000
? 69 468 1
? 290 468 75000
? 290 468 50001
? 11 468 87500
? 468 11 75001
? 209 11 93750...

result:

ok Correct answer

Test #6:

score: 0
Accepted
time: 46ms
memory: 3464kb

input:

500
EQUAL
EQUAL
EQUAL
EQUAL
EQUAL
EQUAL
EQUAL
EQUAL
EQUAL
EQUAL
EQUAL
EQUAL
EQUAL
EQUAL
EQUAL
EQUAL
EQUAL
EQUAL
EQUAL
EQUAL
EQUAL
EQUAL
EQUAL
EQUAL
EQUAL
EQUAL
EQUAL
EQUAL
EQUAL
EQUAL
EQUAL
EQUAL
EQUAL
EQUAL
EQUAL
EQUAL
EQUAL
EQUAL
EQUAL
EQUAL
EQUAL
EQUAL
EQUAL
EQUAL
EQUAL
EQUAL
EQUAL
EQUAL
EQUAL
EQ...

output:

? 110 290 50000
? 290 110 1
? 290 11 50000
? 11 290 1
? 110 290 25000
? 290 110 1
? 11 69 50000
? 69 11 1
? 290 11 25000
? 11 290 1
? 110 290 12500
? 290 110 1
? 69 209 50000
? 209 69 1
? 11 69 25000
? 69 11 1
? 290 11 12500
? 11 290 1
? 110 290 6250
? 290 110 1
? 209 468 50000
? 468 209 1
? 69 209 ...

result:

ok Correct answer

Test #7:

score: 0
Accepted
time: 28ms
memory: 3540kb

input:

500
SECOND
FIRST
FIRST
FIRST
FIRST
FIRST
FIRST
FIRST
SECOND
FIRST
SECOND
FIRST
FIRST
FIRST
FIRST
FIRST
FIRST
FIRST
SECOND
FIRST
FIRST
FIRST
FIRST
FIRST
FIRST
FIRST
SECOND
FIRST
SECOND
FIRST
FIRST
FIRST
FIRST
FIRST
SECOND
FIRST
SECOND
FIRST
SECOND
FIRST
SECOND
FIRST
FIRST
FIRST
FIRST
FIRST
FIRST
FIRS...

output:

? 110 290 50000
? 290 110 1
? 290 11 50000
? 290 11 1
? 110 11 75000
? 110 11 50001
? 290 69 50000
? 290 69 1
? 110 69 75000
? 69 110 50001
? 11 110 87500
? 110 11 75001
? 290 209 50000
? 290 209 1
? 69 209 75000
? 69 209 50001
? 110 209 87500
? 110 209 75001
? 11 209 93750
? 209 11 87501
? 290 468 ...

result:

ok Correct answer

Test #8:

score: 0
Accepted
time: 24ms
memory: 3524kb

input:

500
FIRST
FIRST
SECOND
FIRST
SECOND
FIRST
SECOND
FIRST
SECOND
FIRST
SECOND
FIRST
FIRST
FIRST
FIRST
FIRST
FIRST
FIRST
SECOND
FIRST
SECOND
FIRST
SECOND
FIRST
SECOND
FIRST
SECOND
FIRST
SECOND
FIRST
FIRST
FIRST
FIRST
FIRST
FIRST
FIRST
FIRST
FIRST
FIRST
FIRST
SECOND
FIRST
FIRST
FIRST
SECOND
FIRST
SECOND
...

output:

? 110 290 50000
? 110 290 1
? 110 11 50000
? 11 110 1
? 290 110 75000
? 110 290 50001
? 11 69 50000
? 69 11 1
? 110 11 75000
? 11 110 50001
? 290 110 87500
? 110 290 75001
? 69 209 50000
? 69 209 1
? 11 209 75000
? 11 209 50001
? 110 209 87500
? 110 209 75001
? 290 209 93750
? 209 290 87501
? 69 468...

result:

ok Correct answer

Test #9:

score: 0
Accepted
time: 4ms
memory: 3444kb

input:

2
SECOND
SECOND
QUESTION 64500
QUESTION 22602
FIRST
QUESTION 37446
FIRST
QUESTION 97972
QUESTION 78630
QUESTION 75591
QUESTION 63328
QUESTION 64746
QUESTION 94532
QUESTION 51275
QUESTION 12189
FIRST
QUESTION 64341
QUESTION 85825
QUESTION 63713
QUESTION 36778
FIRST
QUESTION 27116
FIRST
QUESTION 18630...

output:

? 0 1 50000
? 1 0 1
!
! 1
? 1 0 22602
! 1
? 1 0 37446
! 1
! 1
! 1
! 1
! 1
! 1
! 1
! 1
? 1 0 12189
! 1
! 1
! 1
! 1
? 1 0 36778
! 1
? 1 0 27116
! 1
? 1 0 18630
! 1
! 1
? 1 0 28074
! 1
! 1
! 1
? 1 0 39195
! 1
! 1
? 1 0 1182
! 1
! 1
! 1
! 1
? 1 0 7017
! 1
? 1 0 13589
! 1
! 1
! 1
? 1 0 48324
! 1
! 1
! 1
...

result:

ok Correct answer

Test #10:

score: 0
Accepted
time: 2ms
memory: 3456kb

input:

2
SECOND
SECOND
QUESTION 54311
QUESTION 8466
SECOND
QUESTION 82055
QUESTION 65419
QUESTION 5271
SECOND
QUESTION 4799
SECOND
QUESTION 21521
FIRST
QUESTION 66767
QUESTION 24897
FIRST
QUESTION 69127
QUESTION 84527
QUESTION 23303
FIRST
QUESTION 88924
QUESTION 56421
QUESTION 88108
QUESTION 74033
QUESTION...

output:

? 0 1 50000
? 1 0 1
!
! 1
? 1 0 8466
! 0
! 1
! 1
? 1 0 5271
! 0
? 1 0 4799
! 0
? 1 0 21521
! 1
! 1
? 1 0 24897
! 1
! 1
! 1
? 1 0 23303
! 1
! 1
! 1
! 1
! 1
? 1 0 25348
! 1
? 1 0 10105
! 0
! 1
? 1 0 33359
! 1
? 1 0 49782
! 1
? 1 0 20392
! 1
! 1
! 1
? 1 0 4246
! 0
! 1
? 1 0 8620
! 0
? 1 0 30435
! 1
? 1...

result:

ok Correct answer

Test #11:

score: 0
Accepted
time: 45ms
memory: 3480kb

input:

500
SECOND
SECOND
SECOND
SECOND
SECOND
SECOND
FIRST
SECOND
FIRST
SECOND
SECOND
SECOND
FIRST
SECOND
FIRST
SECOND
SECOND
SECOND
SECOND
SECOND
FIRST
SECOND
FIRST
SECOND
FIRST
SECOND
FIRST
SECOND
SECOND
SECOND
SECOND
SECOND
SECOND
SECOND
SECOND
SECOND
SECOND
SECOND
SECOND
SECOND
SECOND
SECOND
FIRST
SECO...

output:

? 110 290 50000
? 290 110 1
? 290 11 50000
? 11 290 1
? 110 290 25000
? 290 110 1
? 11 69 50000
? 11 69 1
? 290 69 25000
? 290 69 1
? 110 69 12500
? 69 110 1
? 11 209 50000
? 11 209 1
? 290 209 25000
? 290 209 1
? 69 209 12500
? 209 69 1
? 110 69 6250
? 69 110 1
? 11 468 50000
? 11 468 1
? 290 468 2...

result:

ok Correct answer

Test #12:

score: 0
Accepted
time: 17ms
memory: 3456kb

input:

500
SECOND
SECOND
FIRST
SECOND
SECOND
SECOND
FIRST
SECOND
FIRST
SECOND
SECOND
FIRST
SECOND
SECOND
FIRST
FIRST
FIRST
SECOND
FIRST
SECOND
SECOND
FIRST
SECOND
FIRST
FIRST
SECOND
FIRST
SECOND
SECOND
SECOND
FIRST
SECOND
FIRST
FIRST
SECOND
SECOND
FIRST
SECOND
FIRST
SECOND
FIRST
SECOND
FIRST
SECOND
FIRST
S...

output:

? 110 290 50000
? 290 110 1
? 290 11 50000
? 290 11 1
? 110 11 25000
? 11 110 1
? 290 69 50000
? 290 69 1
? 11 69 25000
? 11 69 1
? 110 69 12500
? 69 110 1
? 290 209 50000
? 209 290 1
? 11 290 25000
? 11 290 1
? 209 468 50000
? 209 468 1
? 11 468 25000
? 11 468 1
? 69 468 12500
? 468 69 1
? 110 69 1...

result:

ok Correct answer

Test #13:

score: 0
Accepted
time: 42ms
memory: 3504kb

input:

500
SECOND
SECOND
FIRST
SECOND
FIRST
SECOND
FIRST
SECOND
FIRST
SECOND
SECOND
SECOND
FIRST
SECOND
FIRST
SECOND
SECOND
SECOND
SECOND
SECOND
SECOND
SECOND
SECOND
SECOND
SECOND
SECOND
SECOND
SECOND
SECOND
SECOND
FIRST
SECOND
SECOND
SECOND
SECOND
SECOND
SECOND
SECOND
SECOND
SECOND
SECOND
SECOND
FIRST
SEC...

output:

? 110 290 50000
? 290 110 1
? 290 11 50000
? 290 11 1
? 110 11 25000
? 110 11 1
? 290 69 50000
? 290 69 1
? 110 69 25000
? 110 69 1
? 11 69 12500
? 69 11 1
? 290 209 50000
? 290 209 1
? 110 209 25000
? 110 209 1
? 69 209 12500
? 209 69 1
? 11 69 6250
? 69 11 1
? 290 468 50000
? 468 290 1
? 110 290 2...

result:

ok Correct answer

Test #14:

score: 0
Accepted
time: 25ms
memory: 3476kb

input:

500
SECOND
SECOND
FIRST
SECOND
SECOND
SECOND
SECOND
SECOND
SECOND
SECOND
FIRST
FIRST
FIRST
SECOND
FIRST
SECOND
FIRST
SECOND
FIRST
FIRST
FIRST
SECOND
FIRST
SECOND
FIRST
SECOND
FIRST
FIRST
FIRST
SECOND
FIRST
SECOND
FIRST
FIRST
FIRST
FIRST
FIRST
SECOND
FIRST
FIRST
SECOND
FIRST
FIRST
SECOND
FIRST
SECOND...

output:

? 110 290 50000
? 290 110 1
? 290 11 50000
? 290 11 1
? 110 11 25000
? 11 110 1
? 290 69 50000
? 69 290 1
? 11 290 25000
? 290 11 1
? 110 11 12500
? 110 11 1
? 69 209 50000
? 69 209 1
? 290 209 25000
? 290 209 1
? 110 209 12500
? 110 209 1
? 69 468 50000
? 69 468 1
? 69 17 50000
? 69 17 1
? 290 17 2...

result:

ok Correct answer

Test #15:

score: 0
Accepted
time: 17ms
memory: 3452kb

input:

500
SECOND
SECOND
FIRST
SECOND
FIRST
FIRST
FIRST
SECOND
FIRST
SECOND
FIRST
SECOND
FIRST
FIRST
SECOND
SECOND
FIRST
SECOND
FIRST
FIRST
FIRST
SECOND
FIRST
SECOND
FIRST
SECOND
FIRST
FIRST
FIRST
FIRST
FIRST
SECOND
FIRST
SECOND
FIRST
FIRST
FIRST
SECOND
SECOND
SECOND
FIRST
FIRST
FIRST
FIRST
FIRST
SECOND
FI...

output:

? 110 290 50000
? 290 110 1
? 290 11 50000
? 290 11 1
? 110 11 25000
? 110 11 1
? 290 69 50000
? 290 69 1
? 110 69 25000
? 110 69 1
? 290 209 50000
? 290 209 1
? 110 209 25000
? 110 209 1
? 11 209 37500
? 209 11 25001
? 290 468 50000
? 290 468 1
? 110 468 25000
? 110 468 1
? 209 468 37500
? 209 468 ...

result:

ok Correct answer

Test #16:

score: 0
Accepted
time: 26ms
memory: 3464kb

input:

500
SECOND
SECOND
FIRST
SECOND
SECOND
SECOND
FIRST
SECOND
FIRST
SECOND
SECOND
SECOND
SECOND
SECOND
SECOND
SECOND
SECOND
SECOND
SECOND
SECOND
FIRST
SECOND
FIRST
SECOND
FIRST
SECOND
SECOND
FIRST
FIRST
SECOND
FIRST
SECOND
FIRST
SECOND
FIRST
SECOND
FIRST
SECOND
FIRST
SECOND
FIRST
SECOND
FIRST
SECOND
SEC...

output:

? 110 290 50000
? 290 110 1
? 290 11 50000
? 290 11 1
? 110 11 25000
? 11 110 1
? 290 69 50000
? 290 69 1
? 11 69 25000
? 11 69 1
? 110 69 12500
? 69 110 1
? 290 209 50000
? 209 290 1
? 11 290 25000
? 290 11 1
? 69 11 12500
? 11 69 1
? 110 69 6250
? 69 110 1
? 209 468 50000
? 209 468 1
? 290 468 250...

result:

ok Correct answer