Submission #1020154

#TimeUsernameProblemLanguageResultExecution timeMemory
1020154IssaWerewolf (IOI18_werewolf)C++17
15 / 100
127 ms73776 KiB
#include <bits/stdc++.h> using namespace std; const int maxn = 3e3 + 100; int n; int pref[maxn][maxn]; int suf[maxn][maxn]; vector<int> g[maxn]; int get(int v, int p[]){ if(p[v] == v) return v; return p[v] = get(p[v], p); } void join(int a, int b, int p[]){ p[get(a, p)] = get(b, p); } void add(vector<int> &v){ for(int &x: v) x++; } vector<int> check_validity(int N, std::vector<int> X, std::vector<int> Y, std::vector<int> S, std::vector<int> E, std::vector<int> L, std::vector<int> R){ add(X); add(Y); add(S); add(E); add(L); add(R); for(int i = 0; i < X.size(); i++){ g[X[i]].push_back(Y[i]); g[Y[i]].push_back(X[i]); } n = N; for(int i = 1; i <= n; i++){ pref[0][i] = suf[n+1][i] = i; } for(int i = 1; i <= n; i++){ for(int j = 1; j <= n; j++){ pref[i][j] = pref[i-1][j]; } for(int to: g[i]){ if(to < i) join(to, i, pref[i]); } } for(int i = n; i > 0; i--){ for(int j = 1; j <= n; j++){ suf[i][j] = suf[i+1][j]; } for(int to: g[i]){ if(to > i) join(to, i, suf[i]); } } vector<int> ans; for(int i = 0; i < S.size(); i++){ int s = S[i], e = E[i]; int l = L[i], r = R[i]; int res = 0; for(int k = l; k <= r; k++){ if(get(s, suf[l]) == get(k, suf[l]) && get(k, pref[r]) == get(e, pref[r])){ res = 1; } } ans.push_back(res); } return ans; }

Compilation message (stderr)

werewolf.cpp: In function 'std::vector<int> check_validity(int, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
werewolf.cpp:28:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |     for(int i = 0; i < X.size(); i++){
      |                    ~~^~~~~~~~~~
werewolf.cpp:53:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   53 |     for(int i = 0; i < S.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...