Submission #251100

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
2511002020-07-20 08:20:37kostia244Werewolf (IOI18_werewolf)C++17
100 / 100
1793 ms175512 KiB
#include "werewolf.h"
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
using namespace std;
const int maxn = 1<<18;
using vi = vector<int>;
int TIME = -1;
struct dsu {
vi r, p;
vector<vi> ch;
vector<array<int, 2>> range;
vector<vector<array<int, 2>>> h;
dsu(int n) : r(n, 1), ch(n), h(n), p(n), range(n) {
iota(all(p), 0);
fill(all(range), array<int, 2>{0, 1});
for(int i = 0; i < n; i++) ch[i].push_back(i), h[i].push_back({n+1, i});
}
int par(int i) {
return i == p[i] ? i : p[i] = par(p[i]);
}
void unite(int i, int j) {
i = par(i), j = par(j);
if(i == j) return;
if(r[i] < r[j]) swap(i, j);
p[j] = i;
range[i][1] += r[j];
for(auto v : ch[j]) {
ch[i].push_back(v);
h[v].push_back({TIME, i});
range[v][0] += r[i];
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Compilation message (stderr)

werewolf.cpp: In constructor 'dsu::dsu(int)':
werewolf.cpp:12:32: warning: 'dsu::h' will be initialized after [-Wreorder]
  vector<vector<array<int, 2>>> h;
                                ^
werewolf.cpp:9:8: warning:   'vi dsu::p' [-Wreorder]
  vi r, p;
        ^
werewolf.cpp:13:2: warning:   when initialized here [-Wreorder]
  dsu(int n) : r(n, 1), ch(n), h(n), p(n), range(n) {
  ^~~
werewolf.cpp: In function 'vi check_validity(int, vi, vi, vi, vi, vi, vi)':
werewolf.cpp:42:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0; i < x.size(); i++) {
                 ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...