# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
158581 | Lawliet | One-Way Streets (CEOI17_oneway) | C++14 | 178 ms | 23128 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100010;
int n, m, q;
int curTime;
int ans[MAXN];
int low[MAXN];
int pre[MAXN];
int sub[MAXN];
vector< int > adj[MAXN];
vector< int > indEdge[MAXN];
vector< int > direction[MAXN];
int min(int& a, int& b)
{
if(a < b) return a;
return b;
}
void DFSLowlink(int cur, int p)
{
low[ cur ] = pre[ cur ] = ++curTime;
for(int i = 0 ; i < adj[ cur ].size() ; i++)
{
int viz = adj[ cur ][ i ];
int ind = indEdge[ cur ][ i ];
int d = direction[ cur ][ i ];
if( pre[ viz ] != 0 )
{
if( ind != p ) low[ cur ] = min(low[ cur ] , pre[ viz ]);
continue;
}
DFSLowlink( viz , ind );
if( low[ viz ] > pre[ cur ] )
{
if( sub[ viz ] > 0 ) ans[ ind ] = d;
if( sub[ viz ] < 0 ) ans[ ind ] = 3 - d;
}
sub[ cur ] += sub[ viz ];
low[ cur ] = min(low[ cur ] , low[ viz ]);
}
}
int main()
{
scanf("%d %d",&n,&m);
for(int i = 1 ; i <= m ; i++)
{
int U, V;
scanf("%d %d",&U,&V);
adj[ U ].push_back( V );
adj[ V ].push_back( U );
indEdge[ U ].push_back( i );
indEdge[ V ].push_back( i );
direction[ U ].push_back( 1 );
direction[ V ].push_back( 2 );
}
scanf("%d",&q);
for(int i = 1 ; i <= q ; i++)
{
int X, Y;
scanf("%d %d",&X,&Y);
sub[ X ]++;
sub[ Y ]--;
}
for(int i = 1 ; i <= n ; i++)
if( pre[ i ] == 0 ) DFSLowlink( i , 0 );
for(int i = 1 ; i <= m ; i++)
{
if(ans[ i ] == 0) printf("B");
if(ans[ i ] == 1) printf("L");
if(ans[ i ] == 2) printf("R");
}
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |