Submission #1093183

# Submission time Handle Problem Language Result Execution time Memory
1093183 2024-09-26T07:33:09 Z Fran ICC (CEOI16_icc) C++17
100 / 100
108 ms 656 KB
#include "icc.h"

#include<bits/stdc++.h>
using namespace std;

constexpr int N = 101;

int rang[N];

vector<int> ver[N];

int qry(vector<int> a, vector<int> b) {
  return query(a.size(), b.size(), &a[0], &b[0]);
}

int find(vector<int> a, vector<int> b) {
  if(a.size() == 1) return a[0];

  int mid = a.size() / 2;
  auto lv = vector(a.begin(), a.begin()+mid), rv = vector(a.begin()+mid, a.end());
  return qry(lv, b) ? find(lv, b) : find(rv, b);
}

void run(int n) {
  iota(rang, rang+n+1, 0);
  for(int i = 1; i <= n; ++i) ver[i].push_back(i);
  for(int e = 0; e < n - 1; ++e) {
    vector<int> root;
    for(int i = 1; i <= n; ++i) if(rang[i] == i) root.push_back(i);
    int roots = root.size();
    int x = 0, k = -1;
    for(int i = 0; (1 << i) < roots; ++i) {
      vector<int> a, b;
      for(int j = 0; j < roots; ++j) {
        auto& v = (j >> i) & 1 ? a : b;
        v.insert(v.end(), ver[root[j]].begin(), ver[root[j]].end());
      }
      if(qry(a, b)) {
        x ^= (1 << i);
        k = i;
      }
    }
    int y = 0;
    for(int i = 0; (1 << i) < roots; ++i) {
      vector<int> a, b;
      for(int j = 0; j < roots; ++j) {
        auto& v = j & (1 << i | 1 << k) ? a : b;
        v.insert(v.end(), ver[root[j]].begin(), ver[root[j]].end());
      }
      if(!qry(a, b)) y ^= (1 << i);
    }
    x ^= y;

    int u = find(ver[root[x]], ver[root[y]]);
    int v = find(ver[root[y]], ver[root[x]]);
    setRoad(u, v);
    for(auto& x : ver[rang[v]]) {
      rang[x] = rang[u];
      ver[rang[u]].push_back(x);
    }
  }
}
# Verdict Execution time Memory Grader output
1 Correct 6 ms 604 KB Ok! 131 queries used.
2 Correct 5 ms 640 KB Ok! 129 queries used.
# Verdict Execution time Memory Grader output
1 Correct 31 ms 604 KB Ok! 702 queries used.
2 Correct 26 ms 608 KB Ok! 607 queries used.
3 Correct 26 ms 644 KB Ok! 648 queries used.
# Verdict Execution time Memory Grader output
1 Correct 102 ms 640 KB Ok! 1699 queries used.
2 Correct 74 ms 648 KB Ok! 1471 queries used.
3 Correct 86 ms 640 KB Ok! 1712 queries used.
4 Correct 83 ms 636 KB Ok! 1674 queries used.
# Verdict Execution time Memory Grader output
1 Correct 84 ms 608 KB Ok! 1705 queries used.
2 Correct 85 ms 656 KB Ok! 1638 queries used.
3 Correct 108 ms 600 KB Ok! 1587 queries used.
4 Correct 84 ms 600 KB Ok! 1706 queries used.
# Verdict Execution time Memory Grader output
1 Correct 79 ms 632 KB Ok! 1552 queries used.
2 Correct 81 ms 628 KB Ok! 1532 queries used.
3 Correct 76 ms 600 KB Ok! 1523 queries used.
4 Correct 82 ms 600 KB Ok! 1551 queries used.
5 Correct 84 ms 600 KB Ok! 1707 queries used.
6 Correct 83 ms 604 KB Ok! 1674 queries used.
# Verdict Execution time Memory Grader output
1 Correct 81 ms 600 KB Ok! 1547 queries used.
2 Correct 77 ms 644 KB Ok! 1519 queries used.