# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1021044 | 2024-07-12T13:13:07 Z | JakobZorz | 늑대인간 (IOI18_werewolf) | C++17 | 4000 ms | 94108 KB |
#include"werewolf.h" #include<queue> #include<iostream> #include<set> #include<algorithm> using namespace std; int n,m,q; vector<int>nodes[200000]; struct Query{ int S,E,L,R; int ans; }; bool cmp(Query*a,Query*b){ return a->L>b->L; } 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=(int)X.size(); q=(int)S.size(); for(int i=0;i<n;i++){ nodes[i].clear(); } for(int i=0;i<m;i++){ nodes[X[i]].push_back(Y[i]); nodes[Y[i]].push_back(X[i]); } vector<int>line; { vector<int>comp(n); vector<vector<int>>comps(n); for(int i=0;i<n;i++){ comps[i]={i}; set<int>to_add; for(int ne:nodes[i]){ if(ne>i) continue; to_add.insert(comp[ne]); } for(int j:to_add){ comps[i].insert(comps[i].end(),comps[j].begin(),comps[j].end()); comps[i].push_back(i); } for(int j:comps[i]) comp[j]=i; } line=comps[comp[0]]; } vector<int>to_line(n); for(int i=0;i<(int)line.size();i++){ to_line[line[i]]=i; } /*for(int i:line) cout<<i<<" "; cout<<"\n";*/ vector<Query*>qrs(q); for(int i=0;i<q;i++){ qrs[i]=new Query; qrs[i]->S=S[i]; qrs[i]->E=E[i]; qrs[i]->L=L[i]; qrs[i]->R=R[i]; qrs[i]->ans=0; } vector<Query*>srt=qrs; sort(srt.begin(),srt.end(),cmp); vector<int>comp(n); vector<vector<int>>comps(n); vector<vector<int>>comps_line(n); int r=n-1; for(auto qry:srt){ while(r>=qry->L){ comp[r]=r; comps[r]={r}; for(int ne:nodes[r]){ if(ne<r) continue; if(comp[ne]!=comp[r]){ comps[comp[r]].insert(comps[comp[r]].end(),comps[comp[ne]].begin(),comps[comp[ne]].end()); for(int i:comps[comp[r]]) comp[i]=comp[r]; } } r--; } int rl,rr; for(int j=0;j<(int)line.size();j++){ if(line[j]==qry->E){ for(rr=j;rr<(int)line.size()&&line[rr]<=qry->R;rr++); for(rl=j;rl>=0&&line[rl]<=qry->R;rl--); break; } } for(int i:comps[comp[qry->S]]){ if(rl<to_line[i]&&to_line[i]<rr) qry->ans=1; } } vector<int>res(q); for(int i=0;i<q;i++) res[i]=qrs[i]->ans; return res; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 5208 KB | Output is correct |
2 | Correct | 2 ms | 4956 KB | Output is correct |
3 | Correct | 3 ms | 4956 KB | Output is correct |
4 | Correct | 3 ms | 4956 KB | Output is correct |
5 | Correct | 2 ms | 4956 KB | Output is correct |
6 | Correct | 2 ms | 4956 KB | Output is correct |
7 | Correct | 3 ms | 4956 KB | Output is correct |
8 | Correct | 3 ms | 5072 KB | Output is correct |
9 | Correct | 3 ms | 5212 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 5208 KB | Output is correct |
2 | Correct | 2 ms | 4956 KB | Output is correct |
3 | Correct | 3 ms | 4956 KB | Output is correct |
4 | Correct | 3 ms | 4956 KB | Output is correct |
5 | Correct | 2 ms | 4956 KB | Output is correct |
6 | Correct | 2 ms | 4956 KB | Output is correct |
7 | Correct | 3 ms | 4956 KB | Output is correct |
8 | Correct | 3 ms | 5072 KB | Output is correct |
9 | Correct | 3 ms | 5212 KB | Output is correct |
10 | Correct | 42 ms | 32856 KB | Output is correct |
11 | Correct | 33 ms | 22352 KB | Output is correct |
12 | Correct | 13 ms | 6236 KB | Output is correct |
13 | Correct | 51 ms | 69592 KB | Output is correct |
14 | Correct | 78 ms | 69204 KB | Output is correct |
15 | Correct | 25 ms | 23384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 4046 ms | 94108 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 5208 KB | Output is correct |
2 | Correct | 2 ms | 4956 KB | Output is correct |
3 | Correct | 3 ms | 4956 KB | Output is correct |
4 | Correct | 3 ms | 4956 KB | Output is correct |
5 | Correct | 2 ms | 4956 KB | Output is correct |
6 | Correct | 2 ms | 4956 KB | Output is correct |
7 | Correct | 3 ms | 4956 KB | Output is correct |
8 | Correct | 3 ms | 5072 KB | Output is correct |
9 | Correct | 3 ms | 5212 KB | Output is correct |
10 | Correct | 42 ms | 32856 KB | Output is correct |
11 | Correct | 33 ms | 22352 KB | Output is correct |
12 | Correct | 13 ms | 6236 KB | Output is correct |
13 | Correct | 51 ms | 69592 KB | Output is correct |
14 | Correct | 78 ms | 69204 KB | Output is correct |
15 | Correct | 25 ms | 23384 KB | Output is correct |
16 | Execution timed out | 4046 ms | 94108 KB | Time limit exceeded |
17 | Halted | 0 ms | 0 KB | - |