# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
1009895 |
2024-06-28T07:27:35 Z |
pcc |
게임 (APIO22_game) |
C++17 |
|
1224 ms |
39140 KB |
#include "game.h"
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,popcnt,sse4")
const int mxk = 1010;
const int mxn = 3e4+10;
bool flag = false;
char cnt[mxk*mxn];
int N,K;
void add(int k){
assert(k<mxn*mxk);
cnt[k]++;
if(cnt[k]>=2)flag = true;
return;
}
const int LEN = 1e5+10;
int head[LEN],to[LEN],nid[LEN],p1;
int rhead[LEN],rto[LEN],rnid[LEN],p2;
void add_edge(short a,short b){
assert(p1<LEN);
//cerr<<a<<','<<b<<':'<<p1<<endl;
p1++;
nid[p1] = head[a];
to[p1] = b;
head[a] = p1;
}
void radd_edge(short a,short b){
assert(p2<LEN);
p2++;
rnid[p2] = rhead[a];
rto[p2] = b;
rhead[a] = p2;
return;
}
struct DS{
bitset<mxn> vis,rvis;
short id;
DS(short ii = 0):id(ii){vis.reset();rvis.reset();}
queue<short> q;
void BFS(short now){
if(vis[now])return;
q.push(now);
vis[now] = true;add(N*id+now);
while(!q.empty()){
auto now = q.front();
q.pop();
for(int eid = head[now];eid;eid = nid[eid]){
int nxt = to[eid];
if(vis[nxt])continue;
vis[nxt] = true;add(N*id+nxt);
q.push(nxt);
}
}
return;
}
void RBFS(short now){
if(rvis[now])return;
q.push(now);
rvis[now] = true;add(N*id+now);
while(!q.empty()){
auto now = q.front();
q.pop();
for(int eid = rhead[now];eid;eid = rnid[eid]){
int nxt = rto[eid];
if(rvis[nxt])continue;
rvis[nxt] = true;add(N*id+nxt);
q.push(nxt);
}
}
return;
}
void add_edge(short a,short b){
if(vis[a])BFS(b);
if(rvis[b])RBFS(a);
return;
}
};
DS arr[mxk];
void init(int n, int k) {
N = n,K = k;
for(int i = 0;i<k;i++){
arr[i].id = i;
arr[i].vis[i] = arr[i].rvis[i] = 1;
}
for(short i = 0;i<=k-2;i++){
add_edge(i,i+1);
radd_edge(i+1,i);
for(short j = 0;j<k;j++){
arr[j].add_edge(i,i+1);
}
}
flag = false;
/*
cerr<<"INIT DONE!"<<endl;
for(int i = 0;i<K;i++){
for(int j = 0;j<N;j++)cerr<<arr[i].vis[j];cerr<<endl;
for(int j = 0;j<N;j++)cerr<<arr[i].rvis[j];cerr<<endl;
cerr<<endl;
}
*/
return;
}
int add_teleporter(int u, int v) {
if(u == v){
return (u<K);
}
add_edge(u,v);
radd_edge(v,u);
for(short i = 0;i<K;i++){
arr[i].add_edge(u,v);
}
return flag;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
8536 KB |
Output is correct |
2 |
Correct |
3 ms |
8536 KB |
Output is correct |
3 |
Correct |
4 ms |
8536 KB |
Output is correct |
4 |
Correct |
3 ms |
8536 KB |
Output is correct |
5 |
Correct |
4 ms |
8536 KB |
Output is correct |
6 |
Correct |
3 ms |
8536 KB |
Output is correct |
7 |
Correct |
3 ms |
8536 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
8536 KB |
Output is correct |
2 |
Correct |
3 ms |
8536 KB |
Output is correct |
3 |
Correct |
4 ms |
8536 KB |
Output is correct |
4 |
Correct |
3 ms |
8536 KB |
Output is correct |
5 |
Correct |
4 ms |
8536 KB |
Output is correct |
6 |
Correct |
3 ms |
8536 KB |
Output is correct |
7 |
Correct |
3 ms |
8536 KB |
Output is correct |
8 |
Correct |
4 ms |
8536 KB |
Output is correct |
9 |
Correct |
4 ms |
8536 KB |
Output is correct |
10 |
Correct |
3 ms |
8536 KB |
Output is correct |
11 |
Correct |
5 ms |
8536 KB |
Output is correct |
12 |
Correct |
3 ms |
8536 KB |
Output is correct |
13 |
Correct |
3 ms |
8536 KB |
Output is correct |
14 |
Correct |
4 ms |
8536 KB |
Output is correct |
15 |
Correct |
4 ms |
8536 KB |
Output is correct |
16 |
Correct |
3 ms |
8536 KB |
Output is correct |
17 |
Correct |
3 ms |
8536 KB |
Output is correct |
18 |
Correct |
3 ms |
8536 KB |
Output is correct |
19 |
Correct |
3 ms |
8536 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
8536 KB |
Output is correct |
2 |
Correct |
3 ms |
8536 KB |
Output is correct |
3 |
Correct |
4 ms |
8536 KB |
Output is correct |
4 |
Correct |
3 ms |
8536 KB |
Output is correct |
5 |
Correct |
4 ms |
8536 KB |
Output is correct |
6 |
Correct |
3 ms |
8536 KB |
Output is correct |
7 |
Correct |
3 ms |
8536 KB |
Output is correct |
8 |
Correct |
4 ms |
8536 KB |
Output is correct |
9 |
Correct |
4 ms |
8536 KB |
Output is correct |
10 |
Correct |
3 ms |
8536 KB |
Output is correct |
11 |
Correct |
5 ms |
8536 KB |
Output is correct |
12 |
Correct |
3 ms |
8536 KB |
Output is correct |
13 |
Correct |
3 ms |
8536 KB |
Output is correct |
14 |
Correct |
4 ms |
8536 KB |
Output is correct |
15 |
Correct |
4 ms |
8536 KB |
Output is correct |
16 |
Correct |
3 ms |
8536 KB |
Output is correct |
17 |
Correct |
3 ms |
8536 KB |
Output is correct |
18 |
Correct |
3 ms |
8536 KB |
Output is correct |
19 |
Correct |
3 ms |
8536 KB |
Output is correct |
20 |
Correct |
4 ms |
8536 KB |
Output is correct |
21 |
Correct |
3 ms |
8512 KB |
Output is correct |
22 |
Correct |
6 ms |
8936 KB |
Output is correct |
23 |
Correct |
3 ms |
8528 KB |
Output is correct |
24 |
Correct |
9 ms |
8832 KB |
Output is correct |
25 |
Correct |
12 ms |
8792 KB |
Output is correct |
26 |
Correct |
7 ms |
8744 KB |
Output is correct |
27 |
Correct |
20 ms |
9048 KB |
Output is correct |
28 |
Correct |
12 ms |
9048 KB |
Output is correct |
29 |
Correct |
20 ms |
9048 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
8536 KB |
Output is correct |
2 |
Correct |
3 ms |
8536 KB |
Output is correct |
3 |
Correct |
4 ms |
8536 KB |
Output is correct |
4 |
Correct |
3 ms |
8536 KB |
Output is correct |
5 |
Correct |
4 ms |
8536 KB |
Output is correct |
6 |
Correct |
3 ms |
8536 KB |
Output is correct |
7 |
Correct |
3 ms |
8536 KB |
Output is correct |
8 |
Correct |
4 ms |
8536 KB |
Output is correct |
9 |
Correct |
4 ms |
8536 KB |
Output is correct |
10 |
Correct |
3 ms |
8536 KB |
Output is correct |
11 |
Correct |
5 ms |
8536 KB |
Output is correct |
12 |
Correct |
3 ms |
8536 KB |
Output is correct |
13 |
Correct |
3 ms |
8536 KB |
Output is correct |
14 |
Correct |
4 ms |
8536 KB |
Output is correct |
15 |
Correct |
4 ms |
8536 KB |
Output is correct |
16 |
Correct |
3 ms |
8536 KB |
Output is correct |
17 |
Correct |
3 ms |
8536 KB |
Output is correct |
18 |
Correct |
3 ms |
8536 KB |
Output is correct |
19 |
Correct |
3 ms |
8536 KB |
Output is correct |
20 |
Correct |
4 ms |
8536 KB |
Output is correct |
21 |
Correct |
3 ms |
8512 KB |
Output is correct |
22 |
Correct |
6 ms |
8936 KB |
Output is correct |
23 |
Correct |
3 ms |
8528 KB |
Output is correct |
24 |
Correct |
9 ms |
8832 KB |
Output is correct |
25 |
Correct |
12 ms |
8792 KB |
Output is correct |
26 |
Correct |
7 ms |
8744 KB |
Output is correct |
27 |
Correct |
20 ms |
9048 KB |
Output is correct |
28 |
Correct |
12 ms |
9048 KB |
Output is correct |
29 |
Correct |
20 ms |
9048 KB |
Output is correct |
30 |
Correct |
34 ms |
12032 KB |
Output is correct |
31 |
Correct |
81 ms |
38152 KB |
Output is correct |
32 |
Correct |
54 ms |
12120 KB |
Output is correct |
33 |
Correct |
10 ms |
9560 KB |
Output is correct |
34 |
Correct |
607 ms |
38612 KB |
Output is correct |
35 |
Correct |
907 ms |
38800 KB |
Output is correct |
36 |
Correct |
68 ms |
12368 KB |
Output is correct |
37 |
Correct |
1086 ms |
38736 KB |
Output is correct |
38 |
Correct |
949 ms |
38736 KB |
Output is correct |
39 |
Correct |
880 ms |
38964 KB |
Output is correct |
40 |
Correct |
729 ms |
39140 KB |
Output is correct |
41 |
Correct |
727 ms |
38736 KB |
Output is correct |
42 |
Correct |
621 ms |
38844 KB |
Output is correct |
43 |
Correct |
1224 ms |
38864 KB |
Output is correct |
44 |
Correct |
699 ms |
38848 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
8536 KB |
Output is correct |
2 |
Correct |
3 ms |
8536 KB |
Output is correct |
3 |
Correct |
4 ms |
8536 KB |
Output is correct |
4 |
Correct |
3 ms |
8536 KB |
Output is correct |
5 |
Correct |
4 ms |
8536 KB |
Output is correct |
6 |
Correct |
3 ms |
8536 KB |
Output is correct |
7 |
Correct |
3 ms |
8536 KB |
Output is correct |
8 |
Correct |
4 ms |
8536 KB |
Output is correct |
9 |
Correct |
4 ms |
8536 KB |
Output is correct |
10 |
Correct |
3 ms |
8536 KB |
Output is correct |
11 |
Correct |
5 ms |
8536 KB |
Output is correct |
12 |
Correct |
3 ms |
8536 KB |
Output is correct |
13 |
Correct |
3 ms |
8536 KB |
Output is correct |
14 |
Correct |
4 ms |
8536 KB |
Output is correct |
15 |
Correct |
4 ms |
8536 KB |
Output is correct |
16 |
Correct |
3 ms |
8536 KB |
Output is correct |
17 |
Correct |
3 ms |
8536 KB |
Output is correct |
18 |
Correct |
3 ms |
8536 KB |
Output is correct |
19 |
Correct |
3 ms |
8536 KB |
Output is correct |
20 |
Correct |
4 ms |
8536 KB |
Output is correct |
21 |
Correct |
3 ms |
8512 KB |
Output is correct |
22 |
Correct |
6 ms |
8936 KB |
Output is correct |
23 |
Correct |
3 ms |
8528 KB |
Output is correct |
24 |
Correct |
9 ms |
8832 KB |
Output is correct |
25 |
Correct |
12 ms |
8792 KB |
Output is correct |
26 |
Correct |
7 ms |
8744 KB |
Output is correct |
27 |
Correct |
20 ms |
9048 KB |
Output is correct |
28 |
Correct |
12 ms |
9048 KB |
Output is correct |
29 |
Correct |
20 ms |
9048 KB |
Output is correct |
30 |
Correct |
34 ms |
12032 KB |
Output is correct |
31 |
Correct |
81 ms |
38152 KB |
Output is correct |
32 |
Correct |
54 ms |
12120 KB |
Output is correct |
33 |
Correct |
10 ms |
9560 KB |
Output is correct |
34 |
Correct |
607 ms |
38612 KB |
Output is correct |
35 |
Correct |
907 ms |
38800 KB |
Output is correct |
36 |
Correct |
68 ms |
12368 KB |
Output is correct |
37 |
Correct |
1086 ms |
38736 KB |
Output is correct |
38 |
Correct |
949 ms |
38736 KB |
Output is correct |
39 |
Correct |
880 ms |
38964 KB |
Output is correct |
40 |
Correct |
729 ms |
39140 KB |
Output is correct |
41 |
Correct |
727 ms |
38736 KB |
Output is correct |
42 |
Correct |
621 ms |
38844 KB |
Output is correct |
43 |
Correct |
1224 ms |
38864 KB |
Output is correct |
44 |
Correct |
699 ms |
38848 KB |
Output is correct |
45 |
Runtime error |
16 ms |
18008 KB |
Execution killed with signal 11 |
46 |
Halted |
0 ms |
0 KB |
- |