답안 #771524

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
771524 2023-07-03T05:51:54 Z ttamx One-Way Streets (CEOI17_oneway) C++14
0 / 100
1 ms 2644 KB
#include<bits/stdc++.h>
#pragma GCC optimize("O3,unroll-loops")

using namespace std;

const int N=1e5+5;

int n,m,p; 
int val[N],val2[N];
char ans[N];
vector<pair<int,int>> adj[N];
bool vis[N],used[N];

void dfs(int u){
    vis[u]=true;
    for(auto [v,i]:adj[u]){
        if(used[i>>1])continue;
        used[i>>1]=true;
        if(!vis[v]){
            dfs(v);
            if(val2[v]>0||!val[v])ans[i>>1];
            else ans[i>>1]=((val[v]>0)^(i&1))?'L':'R';
            val[u]+=val[v];
            val2[u]+=val2[v];
        }else{
            ans[i>>1]='B';
            val2[u]++;
            val2[v]--;
        }
    }
}

int main(){
    cin.tie(nullptr)->sync_with_stdio(false);
    cin >> n >> m;
    for(int i=1;i<=m;i++){
        int u,v;
        cin >> u >> v;
        adj[u].emplace_back(v,i<<1);
        adj[v].emplace_back(u,i<<1|1);
    }
    cin >> p;
    for(int i=1;i<=p;i++){
        int u,v;
        cin >> u >> v;
        val[u]++;
        val[v]--;
    }
    for(int i=1;i<=n;i++)if(!vis[i])dfs(i);
    for(int i=1;i<=m;i++)cout << ans[i];
}

Compilation message

oneway.cpp: In function 'void dfs(int)':
oneway.cpp:16:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   16 |     for(auto [v,i]:adj[u]){
      |              ^
oneway.cpp:21:43: warning: statement has no effect [-Wunused-value]
   21 |             if(val2[v]>0||!val[v])ans[i>>1];
      |                                   ~~~~~~~~^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2644 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2644 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2644 KB Output isn't correct
2 Halted 0 ms 0 KB -