Submission #626790

# Submission time Handle Problem Language Result Execution time Memory
626790 2022-08-11T19:11:30 Z perchuts Werewolf (IOI18_werewolf) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define sz(x) (int) x.size()
#define endl '\n'
#define pb push_back
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#include "werewolf.h"

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ii = pair<int,int>;
using iii = tuple<int,int,int>;

const int inf = 2e9+1;
const int mod = 1e9+7;
const int maxn = 3001;

template<typename X, typename Y> bool ckmin(X& x, const Y& y) { return (y < x) ? (x=y,1):0; }
template<typename X, typename Y> bool ckmax(X& x, const Y& y) { return (x < y) ? (x=y,1):0; }

int curp[maxn], par[maxn][maxn][2], lvl[maxn], tmp[maxn];

int findp(int x){
    return par[x] = (par[x]==x?x:findp(par[x]));
}

void merge(int x,int y){
    x = findp(x), y = findp(y);
    if(x==y)return;
    if(lvl[x]<lvl[y])swap(x,y);
    par[y] = x;
    if(lvl[x]==lvl[y])lvl[x]++;
}

vector<int> check_validity(int N, vector<int> X, vector<int> Y,vector<int> S, vector<int> E,vector<int> L, vector<int> R) {
    int Q = S.size();

    for(int i=0;i<sz(X);++i){
        int u = X[i], v = Y[i];
        g[u].pb(v), g[v].pb(u);
    }

    for(int i=1;i<=N;++i){
        curp[i] = par[i][0][0] = par[i][n+1][1] = i, lvl[i] = 0;
    }

    for(int i=1;i<=N;++i){
        for(auto v:g[i]){
            if(v<i)merge(v,i);
        }
        for(int j=1;j<=N;++j)par[j][i][0] = findp(j);
    }

    for(int i=1;i<=N;++i)curp[i] = i, lvl[i] = 0;

    for(int i=N;i>=1;--i){
        for(auto v:g[i]){
            if(v>i)merge(v,i);
        }
        for(int j=1;j<=N;++j)par[j][i][1] = findp(j);
    }

    vector<int>ans(Q);

    for(int i=0;i<Q;++i){
        for(int j=L[i];j<=R[i];++j){
            ans[i] |= par[j][L[i]][1]==par[S[i]][L[i]][1]&&
            par[j][R[i]][0]==par[E[i]][R[i]][0];
        }
    }

    return ans;
}

Compilation message

werewolf.cpp: In function 'int findp(int)':
werewolf.cpp:26:28: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   26 |     return par[x] = (par[x]==x?x:findp(par[x]));
      |                      ~~~~~~^~~
werewolf.cpp:26:45: error: invalid conversion from 'int (*)[2]' to 'int' [-fpermissive]
   26 |     return par[x] = (par[x]==x?x:findp(par[x]));
      |                                        ~~~~~^
      |                                             |
      |                                             int (*)[2]
werewolf.cpp:25:15: note:   initializing argument 1 of 'int findp(int)'
   25 | int findp(int x){
      |           ~~~~^
werewolf.cpp:26:19: error: incompatible types in assignment of 'int' to 'int [3001][2]'
   26 |     return par[x] = (par[x]==x?x:findp(par[x]));
      |            ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
werewolf.cpp: In function 'void merge(int, int)':
werewolf.cpp:33:12: error: incompatible types in assignment of 'int' to 'int [3001][2]'
   33 |     par[y] = x;
      |     ~~~~~~~^~~
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:42:9: error: 'g' was not declared in this scope
   42 |         g[u].pb(v), g[v].pb(u);
      |         ^
werewolf.cpp:46:41: error: 'n' was not declared in this scope
   46 |         curp[i] = par[i][0][0] = par[i][n+1][1] = i, lvl[i] = 0;
      |                                         ^
werewolf.cpp:50:20: error: 'g' was not declared in this scope
   50 |         for(auto v:g[i]){
      |                    ^
werewolf.cpp:59:20: error: 'g' was not declared in this scope
   59 |         for(auto v:g[i]){
      |                    ^