Submission #1362968

#TimeUsernameProblemLanguageResultExecution timeMemory
1362968SpyrosAlivChameleon's Love (JOI20_chameleon)C++20
0 / 100
0 ms344 KiB
#include "chameleon.h"
#include <vector>
#include <bits/stdc++.h>
using namespace std;

namespace {

int variable_example = 1;

}  // namespace

bool deb = false;

void dbg(vector<int> &x) {
  cout << "DEBUG: ";
  for (auto xx: x) cout << xx << " ";
  cout << "\n";
}

void Solve(int N) {
  int n = N;
  n *= 2;
  vector<vector<int>> cnt(n+1, vector<int>(n+1, 0));
  for (int i = 1; i <= n; i++) {
    vector<int> cands;
    for (int j = 1; j <= n; j++) {
      if (i == j) continue;
      int tot = Query({i, j});
      if (tot == 1) {
        cands.push_back(j);
      }
    }
    dbg(cands);
    assert(cands.size() == 1 || cands.size() == 3);
    if (cands.size() == 1) {
      cnt[min(i, cands[0])][max(i, cands[0])] = 2;
      continue;
    }
    vector<int> use;
    int totA = Query({cands[0], cands[1], i});
    int totB = Query({cands[0], cands[2], i});
    int totC = Query({cands[1], cands[2], i});
    if (totA == 1) use = {cands[0], cands[1]};
    else if (totB == 1) use = {cands[0], cands[2]};
    else if (totC == 1) use = {cands[1], cands[2]};
    else assert(false);
    cnt[min(use[0], i)][max(use[0], i)]++;
    cnt[min(use[1], i)][max(use[1], i)]++;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = i+1; j <= n; j++) {
      if (cnt[i][j] != 2) continue;
      int tot = Query({i, j});
      if (tot == 1) Answer(i, j);
    }
  }
}
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...