Submission #700956

# Submission time Handle Problem Language Result Execution time Memory
700956 2023-02-19T13:41:43 Z mychecksedad Werewolf (IOI18_werewolf) C++17
15 / 100
4000 ms 22076 KB
#include <bits/stdc++.h>
using namespace std;

struct Dsu{
  vector<int> p, s;
  Dsu(int n){
    s.resize(n + 1, 1);
    p.resize(n + 1);
    for(int i = 0; i <= n; ++i) p[i] = i;
  }
  int find(int v){
    if(v==p[v]) return v;
    return (p[v] = find(p[v]));
  }
  void merge(int a, int b){
    a = find(a);
    b = find(b);
    if(a != b){
      if(s[a] > s[b]) swap(a, b);
      p[a] = b;
      s[b] += s[a];
    }
  }
};
int n, m;
vector<int> check_validity(int N, vector<int> X, vector<int> Y, vector<int> S, vector<int> E, vector<int> L, vector<int> R){
  n = N, m = X.size();
  vector<int> ans(S.size());

  for(int q = 0; q < S.size(); ++q){
    Dsu small(n), large(n);
    for(int i = 0; i < m; ++i){
      if(X[i] <= R[q] && Y[i] <= R[q])
        small.merge(X[i], Y[i]);
      if(X[i] >= L[q] && Y[i] >= L[q])
        large.merge(X[i], Y[i]);
    }
    for(int mid = L[q]; mid <= R[q]; ++mid){
      if(small.find(mid) == small.find(E[q]) && large.find(mid) == large.find(S[q])){
        ans[q] = 1;
        break;
      }
    }
  }

  return ans;
}

Compilation message

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:30:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |   for(int q = 0; q < S.size(); ++q){
      |                  ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 308 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 296 KB Output is correct
7 Correct 1 ms 304 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 308 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 296 KB Output is correct
7 Correct 1 ms 304 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 321 ms 596 KB Output is correct
11 Correct 299 ms 596 KB Output is correct
12 Correct 317 ms 724 KB Output is correct
13 Correct 323 ms 596 KB Output is correct
14 Correct 275 ms 596 KB Output is correct
15 Correct 591 ms 668 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 4051 ms 22076 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 308 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 296 KB Output is correct
7 Correct 1 ms 304 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 321 ms 596 KB Output is correct
11 Correct 299 ms 596 KB Output is correct
12 Correct 317 ms 724 KB Output is correct
13 Correct 323 ms 596 KB Output is correct
14 Correct 275 ms 596 KB Output is correct
15 Correct 591 ms 668 KB Output is correct
16 Execution timed out 4051 ms 22076 KB Time limit exceeded
17 Halted 0 ms 0 KB -