답안 #585173

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
585173 2022-06-28T11:38:32 Z 20160161simone 늑대인간 (IOI18_werewolf) C++14
15 / 100
4000 ms 16272 KB
#include "werewolf.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=2e5+10;
ll f[2][N];
enum state{ human,wolf };
ll Find(ll x,ll sat){
    if(f[sat][x]<0) return x;
    else return f[sat][x]=Find(f[sat][x],sat);
}
void Union(ll x,ll y,ll sat){
    x=Find(x,sat),y=Find(y,sat);
    if(x==y) return;
    f[sat][y]=x;
}

vector<int> check_validity(int n, vector<int> u, vector<int> v, vector<int> s, vector<int> e,vector<int> l, vector<int> r) {
    ll q = s.size(),m=u.size();
    vector<int> ans;
    for(ll kase=0;kase<q;kase++){

        for(ll i=0;i<n;i++) f[human][i]=f[wolf][i]=-1;

        for(ll i=0;i<m;i++){
            if(u[i]<=r[kase] && v[i]<=r[kase]) Union(u[i],v[i],wolf);
            if(u[i]>=l[kase] && v[i]>=l[kase]) Union(u[i],v[i],human);
        }
        ll flag=0;
        for(ll i=l[kase];i<=r[kase];i++){
            if(Find(s[kase],human)==Find(i,human) && Find(i,wolf)==Find(e[kase],wolf)){
                flag=1;
                break;
            }
        }

        // printf("%lld\nwolf:",kase);
        // for(ll i=0;i<n;i++){
        //     if(Find(s[kase],wolf)==Find(i,wolf)) printf("%lld ",i);
        // }cout<<endl;
        // printf("human:");
        // for(ll i=0;i<n;i++){
        //     if(Find(i,human)==Find(e[kase],human)) printf("%lld ",i);
        // }cout<<endl;

        ans.push_back(flag);
    }
    return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 308 KB Output is correct
3 Correct 1 ms 212 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 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 308 KB Output is correct
3 Correct 1 ms 212 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 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 333 ms 620 KB Output is correct
11 Correct 283 ms 576 KB Output is correct
12 Correct 243 ms 596 KB Output is correct
13 Correct 320 ms 608 KB Output is correct
14 Correct 269 ms 720 KB Output is correct
15 Correct 750 ms 696 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4034 ms 16272 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 308 KB Output is correct
3 Correct 1 ms 212 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 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 333 ms 620 KB Output is correct
11 Correct 283 ms 576 KB Output is correct
12 Correct 243 ms 596 KB Output is correct
13 Correct 320 ms 608 KB Output is correct
14 Correct 269 ms 720 KB Output is correct
15 Correct 750 ms 696 KB Output is correct
16 Execution timed out 4034 ms 16272 KB Time limit exceeded
17 Halted 0 ms 0 KB -