Submission #315103

# Submission time Handle Problem Language Result Execution time Memory
315103 2020-10-22T02:31:50 Z casperwang Mouse (info1cup19_mouse) C++14
Compilation error
0 ms 0 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];
    }
    C = t;
    tmp.clear();
    for (int i = 0; i < N; i++)
      if (!ans[i]) tmp.push_back(guess[i]);
    random_shuffle(tmp.begin(), tmp.end());
    int cnt = 0;
    for (int i = 0; i < N; i++) 
      if (!ans[i]) guess[i] = tmp[cnt++];
  }
  return;
}

Compilation message

mouse.cpp: In function 'void solve(int)':
mouse.cpp:54:34: error: 'guess' was not declared in this scope
   54 |       if (!ans[i]) tmp.push_back(guess[i]);
      |                                  ^~~~~
mouse.cpp:58:20: error: 'guess' was not declared in this scope
   58 |       if (!ans[i]) guess[i] = tmp[cnt++];
      |                    ^~~~~