Submission #35751

# Submission time Handle Problem Language Result Execution time Memory
35751 2017-11-29T09:27:50 Z funcsr ICC (CEOI16_icc) C++14
100 / 100
159 ms 2220 KB
#include "icc.h"
#include <iostream>
#include <vector>
#include <tuple>
#include <algorithm>
#include <set>
#include <cassert>
#define rep(i, n) for (int i=0; i<(n); i++)
#define pb push_back
#define all(x) x.begin(), x.end()

using namespace std;

int ctr = 0;
int query(vector<int> a, vector<int> b) {
  //cout<<"query({";for(int x:a)cout<<x<<",";cout<<"}, {";for(int x:b)cout<<x<<",";cout<<"})\n";
  ctr++;
  int ar[100] = {}, br[100] = {};
  rep(i, a.size()) ar[i] = a[i]+1;
  rep(i, b.size()) br[i] = b[i]+1;
  return query(a.size(), b.size(), ar, br);
}
int N;
int U[100];
vector<int> R[100];
int find(int x) {
  if (U[x] == x) return x;
  return U[x] = find(U[x]);
}
void unite(int x, int y) {
  x = find(x), y = find(y);
  if (x == y) return;
  U[y] = x;
  for (int t : R[y]) R[x].pb(t);
  R[y].clear();
}
vector<int> roots() {
  vector<int> ret;
  rep(i, N) if (find(i) == i) ret.pb(i);
  return ret;
}
pair<vector<int>, vector<int>> divide2() {
  vector<int> vs = roots();
  int n = vs.size();
  ctr = 0;
  rep(e, 7) {
    vector<int> a, b;
    rep(i, n) {
      if ((i>>e)&1) for (int x : R[vs[i]]) a.pb(x);
      else          for (int x : R[vs[i]]) b.pb(x);
    }
    if (query(a, b)) return make_pair(a, b);
  }
  assert(false);
}
int find(vector<int> X, vector<int> other) {
  if (X.size() == 1) return X[0];
  vector<int> a, b;
  int n = X.size();
  rep(i, n) {
    if (i&1) b.pb(X[i]);
    else     a.pb(X[i]);
  }
  if (query(a, other)) return find(a, other);
  else                 return find(b, other);
}

void run(int n) {
  N = n;
  rep(i, N) U[i] = i, R[i].pb(i);

  rep(_, N-1) {
    vector<int> a, b;
    tie(a, b) = divide2();
    int u = find(a, b), v = find(b, a);
    unite(u, v);
    setRoad(u+1, v+1);
  }
}

Compilation message

icc.cpp: In function 'int query(std::vector<int>, std::vector<int>)':
icc.cpp:8:34: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define rep(i, n) for (int i=0; i<(n); i++)
                                  ^
icc.cpp:19:3: note: in expansion of macro 'rep'
   rep(i, a.size()) ar[i] = a[i]+1;
   ^
icc.cpp:8:34: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define rep(i, n) for (int i=0; i<(n); i++)
                                  ^
icc.cpp:20:3: note: in expansion of macro 'rep'
   rep(i, b.size()) br[i] = b[i]+1;
   ^
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2080 KB Ok! 96 queries used.
2 Correct 6 ms 2084 KB Ok! 101 queries used.
# Verdict Execution time Memory Grader output
1 Correct 36 ms 2220 KB Ok! 516 queries used.
2 Correct 46 ms 2088 KB Ok! 667 queries used.
3 Correct 46 ms 2084 KB Ok! 666 queries used.
# Verdict Execution time Memory Grader output
1 Correct 119 ms 2220 KB Ok! 1393 queries used.
2 Correct 156 ms 2088 KB Ok! 1626 queries used.
3 Correct 143 ms 2220 KB Ok! 1488 queries used.
4 Correct 139 ms 2220 KB Ok! 1493 queries used.
# Verdict Execution time Memory Grader output
1 Correct 126 ms 2220 KB Ok! 1451 queries used.
2 Correct 146 ms 2216 KB Ok! 1481 queries used.
3 Correct 153 ms 2220 KB Ok! 1607 queries used.
4 Correct 123 ms 2220 KB Ok! 1410 queries used.
# Verdict Execution time Memory Grader output
1 Correct 149 ms 2212 KB Ok! 1639 queries used.
2 Correct 139 ms 2220 KB Ok! 1580 queries used.
3 Correct 159 ms 2084 KB Ok! 1624 queries used.
4 Correct 156 ms 2220 KB Ok! 1606 queries used.
5 Correct 129 ms 2220 KB Ok! 1460 queries used.
6 Correct 136 ms 2220 KB Ok! 1538 queries used.
# Verdict Execution time Memory Grader output
1 Correct 133 ms 2216 KB Ok! 1607 queries used.
2 Correct 133 ms 2216 KB Ok! 1578 queries used.