Submission #742079

# Submission time Handle Problem Language Result Execution time Memory
742079 2023-05-15T14:50:25 Z Ronin13 Werewolf (IOI18_werewolf) C++14
15 / 100
583 ms 24232 KB
#include "werewolf.h"
#include <bits/stdc++.h>
#define ll long long
#define f first
#define s second
#define pii pair<int,int>
#define pll pair<ll, ll>
#define pb push_back
#define epb emplace_back
#define ull unsigned ll
using namespace std;
const int nmax = 200001;

/*6 6 3
5 1
1 2
1 3
3 4
3 0
5 2
4 2 1 2
4 2 2 2
5 4 3 4
*/
vector <int> p(nmax), sz(nmax);

void make_set(int v){
    p[v]= v;
    sz[v] = 1;
}

int find_set(int v){
    return p[v] == v ? v : p[v] = find_set(p[v]);
}

void union_sets(int a, int b){
    a = find_set(a);
    b = find_set(b);
    if(a == b)
        return;
    if(sz[a] < sz[b])
        swap(a, b);
    p[b] = a;
    sz[a] += sz[b];
}

std::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) {
  int Q = S.size();
  int n = N;
  std::vector<int> A(Q);
  for (int i = 0; i < Q; ++i) {
        for(int j = 0; j < N; j++){
            make_set(j), make_set(n + j);

        }
        for(int j = 0; j < X.size(); j++){
            int u = X[j], v = Y[j];
            if(u <= R[i] && v <= R[i])
                union_sets(u, v);
            if(u >= L[i] && v >= L[i])
                union_sets(u + n, v + n);
        }
        for(int x = L[i]; x <= R[i]; x++){
            if(find_set(x) == find_set(E[i])){
                if(find_set(x + n) == find_set(S[i] + n)) A[i] = 1;
            }
        }
  }
  return A;
}

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:58:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |         for(int j = 0; j < X.size(); j++){
      |                        ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1876 KB Output is correct
2 Correct 1 ms 1876 KB Output is correct
3 Correct 2 ms 1876 KB Output is correct
4 Correct 1 ms 1876 KB Output is correct
5 Correct 2 ms 1876 KB Output is correct
6 Correct 2 ms 1876 KB Output is correct
7 Correct 2 ms 1876 KB Output is correct
8 Correct 2 ms 1876 KB Output is correct
9 Correct 2 ms 1876 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1876 KB Output is correct
2 Correct 1 ms 1876 KB Output is correct
3 Correct 2 ms 1876 KB Output is correct
4 Correct 1 ms 1876 KB Output is correct
5 Correct 2 ms 1876 KB Output is correct
6 Correct 2 ms 1876 KB Output is correct
7 Correct 2 ms 1876 KB Output is correct
8 Correct 2 ms 1876 KB Output is correct
9 Correct 2 ms 1876 KB Output is correct
10 Correct 403 ms 2132 KB Output is correct
11 Correct 377 ms 2132 KB Output is correct
12 Correct 325 ms 2132 KB Output is correct
13 Correct 425 ms 2132 KB Output is correct
14 Correct 358 ms 2108 KB Output is correct
15 Correct 583 ms 2204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 125 ms 24232 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1876 KB Output is correct
2 Correct 1 ms 1876 KB Output is correct
3 Correct 2 ms 1876 KB Output is correct
4 Correct 1 ms 1876 KB Output is correct
5 Correct 2 ms 1876 KB Output is correct
6 Correct 2 ms 1876 KB Output is correct
7 Correct 2 ms 1876 KB Output is correct
8 Correct 2 ms 1876 KB Output is correct
9 Correct 2 ms 1876 KB Output is correct
10 Correct 403 ms 2132 KB Output is correct
11 Correct 377 ms 2132 KB Output is correct
12 Correct 325 ms 2132 KB Output is correct
13 Correct 425 ms 2132 KB Output is correct
14 Correct 358 ms 2108 KB Output is correct
15 Correct 583 ms 2204 KB Output is correct
16 Runtime error 125 ms 24232 KB Execution killed with signal 11
17 Halted 0 ms 0 KB -