Submission #315110

# Submission time Handle Problem Language Result Execution time Memory
315110 2020-10-22T02:36:24 Z casperwang Mouse (info1cup19_mouse) C++14
45 / 100
299 ms 384 KB
#include <bits/stdc++.h>
#include "grader.h"
using namespace std;

void solve(int N) {
  vector <int> g(N), ans(N), tmp;
  for (int i = 0; i < N; i++)
    g[i] = i+1;
  random_shuffle(g.begin(), g.end());
  int C = query(g), t;
  for (int i = 0; i < N; i++) {
    if (ans[i]) continue;
    int a = 0, b = 0;
    for (int j = i+1; j < N; j++) {
      if (ans[j]) continue;
      swap(g[i], g[j]);
      t = query(g);
      swap(g[i], g[j]);
      if (t == C + 2) {
        ans[i] = g[i];
        ans[j] = g[j];
        swap(g[i], g[j]);
        break;
      } else if (t == C + 1) {
        if (!a) a = j;
        else {
          b = j;
          break;
        }
      }
    }
    swap(g[i], g[a]);
    swap(g[i], g[b]);
    t = query(g);
    if (t >= C + 2) {
      ans[i] = g[i];
      ans[a] = g[a];
      if (t == C + 3)
        ans[b] = g[b];
    } else {
      swap(g[i], g[b]);
      swap(g[i], g[a]);
      swap(g[i], g[b]);
      swap(g[i], g[a]);
      t = query(g);
      ans[i] = g[i];
      ans[b] = g[b];
      if (t == C + 3)
        ans[a] = g[a];
    }
    for (int j = i+1; j < N; j++)
      if (!ans[j]) tmp.push_back(g[j]);
    random_shuffle(tmp.begin(), tmp.end());
    int cnt = 0;
    for (int j = i+1; j < N; j++) 
      if (!ans[j]) g[j] = tmp[cnt++];
    tmp.clear();
    C = query(g);
  }
  return;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Correct! Number of queries: 25
2 Correct 0 ms 256 KB Correct! Number of queries: 4
3 Correct 1 ms 384 KB Correct! Number of queries: 11
4 Correct 1 ms 256 KB Correct! Number of queries: 22
5 Correct 1 ms 256 KB Correct! Number of queries: 16
6 Correct 1 ms 256 KB Correct! Number of queries: 13
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Correct! Number of queries: 25
2 Correct 0 ms 256 KB Correct! Number of queries: 4
3 Correct 1 ms 384 KB Correct! Number of queries: 11
4 Correct 1 ms 256 KB Correct! Number of queries: 22
5 Correct 1 ms 256 KB Correct! Number of queries: 16
6 Correct 1 ms 256 KB Correct! Number of queries: 13
7 Correct 8 ms 256 KB Correct! Number of queries: 600
8 Correct 7 ms 256 KB Correct! Number of queries: 500
9 Correct 6 ms 256 KB Correct! Number of queries: 400
10 Correct 8 ms 256 KB Correct! Number of queries: 500
11 Correct 6 ms 256 KB Correct! Number of queries: 400
12 Correct 9 ms 256 KB Correct! Number of queries: 600
13 Correct 8 ms 256 KB Correct! Number of queries: 500
14 Correct 8 ms 256 KB Correct! Number of queries: 600
15 Correct 9 ms 256 KB Correct! Number of queries: 500
16 Correct 7 ms 256 KB Correct! Number of queries: 600
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Correct! Number of queries: 25
2 Correct 0 ms 256 KB Correct! Number of queries: 4
3 Correct 1 ms 384 KB Correct! Number of queries: 11
4 Correct 1 ms 256 KB Correct! Number of queries: 22
5 Correct 1 ms 256 KB Correct! Number of queries: 16
6 Correct 1 ms 256 KB Correct! Number of queries: 13
7 Correct 8 ms 256 KB Correct! Number of queries: 600
8 Correct 7 ms 256 KB Correct! Number of queries: 500
9 Correct 6 ms 256 KB Correct! Number of queries: 400
10 Correct 8 ms 256 KB Correct! Number of queries: 500
11 Correct 6 ms 256 KB Correct! Number of queries: 400
12 Correct 9 ms 256 KB Correct! Number of queries: 600
13 Correct 8 ms 256 KB Correct! Number of queries: 500
14 Correct 8 ms 256 KB Correct! Number of queries: 600
15 Correct 9 ms 256 KB Correct! Number of queries: 500
16 Correct 7 ms 256 KB Correct! Number of queries: 600
17 Incorrect 299 ms 256 KB Too many queries
18 Halted 0 ms 0 KB -