Submission #933089

# Submission time Handle Problem Language Result Execution time Memory
933089 2024-02-25T02:05:23 Z Servant_of_the_Lord One-Way Streets (CEOI17_oneway) C++17
0 / 100
0 ms 348 KB
#include<bits/stdc++.h>
#define ll long long

using namespace std;

main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll x,y,z,a,b,c;
    cin>>x>>y;
    vector<vector<vector<ll>>>v(x);
    for(ll i=0;i<y;i++)
    {
        cin>>a>>b;
        a--,b--;
        v[a].push_back({b,1,i});
        v[b].push_back({a,0,i});
    }
    ll timer=0;
    vector<ll>w(x),u(y);
    cin>>z;
    for(ll i=0;i<z;i++)
    {
        cin>>a>>b;
        a--,b--;
        w[a]++;
        w[b]--;
    }
    vector<ll>id(x),low(x);
    function<void(ll,ll,ll,bool)>dfs=[&](ll a,ll b,ll c,bool d)
    {
        id[a]=low[a]=++timer;
        bool o=false;
        for(ll i=0;i<v[a].size();i++)
        {
            if(v[a][i][0]==b&&!o)
            {
                o=true;
                continue;
            }
            if(!id[v[a][i][0]])
            {
                dfs(v[a][i][0],a,v[a][i][2],v[a][i][1]);
                low[a]=min(low[a],low[v[a][i][0]]);
                w[a]+=w[v[a][i][0]];
            }
            else low[a]=min(low[a],id[v[a][i][0]]);
        }
        if(b==-1)return;
        if(low[a]==id[a])
        {
            if(w[a]==0)u[c]=0;
            else if(w[a]>0)
            {
                if(d)u[c]=1;
                else u[c]=2;
            }
            else
            {
                if(d)u[c]=2;
                else u[c]=1;
            }
        }
        else u[c]=0;
    };
    dfs(0,-1,0,0);
    for(ll i=0;i<y;i++)
    {
        if(u[i]==0)cout<<'B';
        else if(u[i]==1)cout<<'L';
        else cout<<'R';
    }
    cout<<'\n';
}

Compilation message

oneway.cpp:6:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    6 | main()
      | ^~~~
oneway.cpp: In lambda function:
oneway.cpp:35:21: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |         for(ll i=0;i<v[a].size();i++)
      |                    ~^~~~~~~~~~~~
oneway.cpp: In function 'int main()':
oneway.cpp:10:18: warning: unused variable 'c' [-Wunused-variable]
   10 |     ll x,y,z,a,b,c;
      |                  ^
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -