# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
771501 | 2023-07-03T05:27:48 Z | Amylopectin | One-Way Streets (CEOI17_oneway) | C++14 | 69 ms | 33728 KB |
#include <stdio.h> #include <iostream> #include <vector> #include <algorithm> using namespace std; const int mxn = 1e6 + 10,mxi = 1e9 + 10; struct we { int to,idx,dir; }; vector<struct we> pat[mxn] = {}; int par[mxn] = {},vall[mxn] = {},u[mxn] = {},dep[mxn] = {}; char ans[mxn] = {}; int fimi(int l,int r) { if(l < r) { return l; } return r; } int re(int cn,int cidx,int cdir) { int i,j,fn,fidx,fdir,ret = mxi,cva; u[cn] = 1; for(i=0; i<pat[cn].size(); i++) { fn = pat[cn][i].to; fidx = pat[cn][i].idx; fdir = pat[cn][i].dir; if(fidx == cidx) { continue; } if(u[fn] == 1) { ans[fidx] = 'B'; ret = fimi(ret,dep[fn]); continue; } dep[fn] = dep[cn] + 1; cva = re(fn,fidx,fdir); ret = fimi(ret,cva); vall[cn] += vall[fn]; } if(cidx == -1) { return 0; } if(ret < dep[cn] || vall[cn] == 0) { ans[cidx] = 'B'; } else { if(vall[cn] < 0) { if(cdir == 0) { ans[cidx] = 'L'; } else { ans[cidx] = 'R'; } } else { if(cdir == 0) { ans[cidx] = 'R'; } else { ans[cidx] = 'L'; } } } return ret; } int main() { int i,j,q,k,n,m,cn,cm,fn,fm,roo = 1; scanf("%d %d",&n,&m); for(i=0; i<m; i++) { scanf("%d %d",&cn,&cm); pat[cn].push_back({cm,i,1}); pat[cm].push_back({cn,i,0}); } scanf("%d",&q); for(i=0; i<q; i++) { scanf("%d %d",&cn,&cm); vall[cn] ++; vall[cm] --; } for(i=1; i<=n; i++) { if(u[i] == 0) { dep[i] = 0; re(i,-1,-1); } } printf("%s\n",ans); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 12 ms | 23764 KB | Output is correct |
2 | Correct | 12 ms | 23764 KB | Output is correct |
3 | Correct | 12 ms | 23764 KB | Output is correct |
4 | Correct | 12 ms | 23816 KB | Output is correct |
5 | Correct | 12 ms | 23892 KB | Output is correct |
6 | Correct | 11 ms | 23788 KB | Output is correct |
7 | Correct | 12 ms | 23824 KB | Output is correct |
8 | Correct | 12 ms | 23764 KB | Output is correct |
9 | Correct | 12 ms | 23836 KB | Output is correct |
10 | Correct | 12 ms | 23860 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 12 ms | 23764 KB | Output is correct |
2 | Correct | 12 ms | 23764 KB | Output is correct |
3 | Correct | 12 ms | 23764 KB | Output is correct |
4 | Correct | 12 ms | 23816 KB | Output is correct |
5 | Correct | 12 ms | 23892 KB | Output is correct |
6 | Correct | 11 ms | 23788 KB | Output is correct |
7 | Correct | 12 ms | 23824 KB | Output is correct |
8 | Correct | 12 ms | 23764 KB | Output is correct |
9 | Correct | 12 ms | 23836 KB | Output is correct |
10 | Correct | 12 ms | 23860 KB | Output is correct |
11 | Correct | 41 ms | 29272 KB | Output is correct |
12 | Correct | 42 ms | 30056 KB | Output is correct |
13 | Correct | 48 ms | 30880 KB | Output is correct |
14 | Correct | 48 ms | 31348 KB | Output is correct |
15 | Correct | 58 ms | 31308 KB | Output is correct |
16 | Correct | 69 ms | 29376 KB | Output is correct |
17 | Correct | 50 ms | 30736 KB | Output is correct |
18 | Correct | 47 ms | 29372 KB | Output is correct |
19 | Correct | 48 ms | 31884 KB | Output is correct |
20 | Correct | 44 ms | 29396 KB | Output is correct |
21 | Correct | 49 ms | 29192 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 12 ms | 23764 KB | Output is correct |
2 | Correct | 12 ms | 23764 KB | Output is correct |
3 | Correct | 12 ms | 23764 KB | Output is correct |
4 | Correct | 12 ms | 23816 KB | Output is correct |
5 | Correct | 12 ms | 23892 KB | Output is correct |
6 | Correct | 11 ms | 23788 KB | Output is correct |
7 | Correct | 12 ms | 23824 KB | Output is correct |
8 | Correct | 12 ms | 23764 KB | Output is correct |
9 | Correct | 12 ms | 23836 KB | Output is correct |
10 | Correct | 12 ms | 23860 KB | Output is correct |
11 | Correct | 41 ms | 29272 KB | Output is correct |
12 | Correct | 42 ms | 30056 KB | Output is correct |
13 | Correct | 48 ms | 30880 KB | Output is correct |
14 | Correct | 48 ms | 31348 KB | Output is correct |
15 | Correct | 58 ms | 31308 KB | Output is correct |
16 | Correct | 69 ms | 29376 KB | Output is correct |
17 | Correct | 50 ms | 30736 KB | Output is correct |
18 | Correct | 47 ms | 29372 KB | Output is correct |
19 | Correct | 48 ms | 31884 KB | Output is correct |
20 | Correct | 44 ms | 29396 KB | Output is correct |
21 | Correct | 49 ms | 29192 KB | Output is correct |
22 | Correct | 61 ms | 30840 KB | Output is correct |
23 | Correct | 60 ms | 29192 KB | Output is correct |
24 | Correct | 61 ms | 29336 KB | Output is correct |
25 | Correct | 61 ms | 33728 KB | Output is correct |
26 | Correct | 67 ms | 30444 KB | Output is correct |
27 | Correct | 62 ms | 29252 KB | Output is correct |
28 | Correct | 38 ms | 27084 KB | Output is correct |
29 | Correct | 59 ms | 29000 KB | Output is correct |
30 | Correct | 56 ms | 29180 KB | Output is correct |
31 | Correct | 61 ms | 29532 KB | Output is correct |
32 | Correct | 56 ms | 31240 KB | Output is correct |