Submission #742074

# Submission time Handle Problem Language Result Execution time Memory
742074 2023-05-15T14:45:32 Z Ronin13 Werewolf (IOI18_werewolf) C++14
0 / 100
139 ms 24244 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);
            if(j <= R[i] && j >= L[i])union_sets(j, 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);
        }
        if(find_set(E[i]) == 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 Incorrect 2 ms 1876 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1876 KB Output is correct
2 Incorrect 2 ms 1876 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 139 ms 24244 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 Incorrect 2 ms 1876 KB Output isn't correct
3 Halted 0 ms 0 KB -