Submission #938969

# Submission time Handle Problem Language Result Execution time Memory
938969 2024-03-06T02:08:41 Z vjudge1 One-Way Streets (CEOI17_oneway) C++17
0 / 100
3 ms 9052 KB
#include <bits/stdc++.h>
#define ll long long
#define str string
#define ins insert
#define ld long double
#define pb push_back
#define pf push_front
#define pof pop_front()
#define pob pop_back()
#define lb lower_bound
#define ub upper_bound
#define endl "\n"
#define fr first
#define sc second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define sz size()
#define vll vector<ll>
#define bc back()
#define arr array
#define pll vector<pair<ll,ll>>
using namespace std;/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>*/
template<class S,class T>
bool chmin(S &a,const T &b) {
	return a>b?(a=b)==b:false;
}
template<class S,class T>
bool chmax(S &a,const T &b) {
	return a<b?(a=b)==b:false;
}
//void fre(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}
void start(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
const ll inf=1e18;
const ll mod=998244353;
const ll N=1e5+5;
const ld eps=1e-9;
vector<vll> g(N),g2(N);
ll n,m;
ll d[N],up[N];
pair<ll,ll> e[N];
bool br[N];
ll comp[N];
char ans[N];
bool vis[N];
void dfs(ll v,ll x){
    up[v]=d[v];
    ll b;
    for(auto i : g[v]){
        if(i==x) continue;
        if(v==e[i].fr)b=e[i].sc;
        else b=e[i].fr;
        if(d[b]){chmin(up[v],d[b]);continue;}
        d[b]=d[v]+1;
        dfs(b,i);
        chmin(up[v],up[b]);
    }
    if(up[v]>=d[v]){
        br[x]=1;
    }
    chmin(up[v],d[v]-1);
}
void build(ll v,ll x){
    ll b;
    for(auto i : g[v]){
        if(v==e[i].fr)b=e[i].sc;
        else b=e[i].fr;
        if(d[b]<=d[v] || comp[b])continue;
        if(br[i]){
            comp[b]=b;
        }
        else comp[b]=comp[v];
        build(b,i);
    }
}
ll c[N],c2[N];
void dfs2(ll v,ll x){
    ll b;
    for(auto i : g2[v]){
        if(i==x) continue;
        if(v==e[i].fr)b=e[i].sc;
        else b=e[i].fr;
        d[x]=d[v]+1;
        dfs2(b,i);
        c[v]+=c[b];
        c2[v]+=c2[b];
    }
    if(c[v]==c2[v])ans[x]='B';
    else if(c[v]<c2[v]){
        if(e[x].fr==v)ans[x]='L';
        else ans[x]='R';
    }else{
        if(e[x].fr==v)ans[x]='R';
        else ans[x]='L';
    }
}
void solve(){
    ll i,j;
    ll q;
    cin>>n>>m;
    ll a,b;
    for(i=1;i<=m;i++){
        cin>>a>>b;
        e[i]={a,b};
        if(a==b) continue;
        g[a].pb(i);
        g[b].pb(i);
    }
    d[1]=1;
    dfs(1,0);
    comp[1]=1;
    build(1,0);
    for(i=1;i<=m;i++){
        a=e[i].fr,b=e[i].sc;
        if(!br[i])ans[i]='B';
        else {
            g2[comp[a]].pb(i);
            g2[comp[b]].pb(i);
        }
    }
    d[1]=0;
    cin>>q;
    for(i=1;i<=q;i++){
        cin>>a>>b;
        c[comp[a]]++;
        c2[comp[b]]++;
    }
    dfs2(1,0);
    for(i=1;i<=m;i++) cout<<(ans[i]==0 ? 'B' : ans[i]);cout<<endl;
}

signed main(){
	//start();
    ll t=1;
    //cin>>t;
    while(t--) solve();
    return 0;
}
/*





*/

Compilation message

oneway.cpp: In function 'void solve()':
oneway.cpp:136:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
  136 |     for(i=1;i<=m;i++) cout<<(ans[i]==0 ? 'B' : ans[i]);cout<<endl;
      |     ^~~
oneway.cpp:136:56: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
  136 |     for(i=1;i<=m;i++) cout<<(ans[i]==0 ? 'B' : ans[i]);cout<<endl;
      |                                                        ^~~~
oneway.cpp:105:10: warning: unused variable 'j' [-Wunused-variable]
  105 |     ll i,j;
      |          ^
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 9052 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 9052 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 9052 KB Output isn't correct
2 Halted 0 ms 0 KB -