Submission #1010379

# Submission time Handle Problem Language Result Execution time Memory
1010379 2024-06-29T02:45:35 Z vjudge1 One-Way Streets (CEOI17_oneway) C++17
0 / 100
3 ms 5464 KB
#include <bits/stdc++.h>

using namespace std;

#define task "test"
#define FOR(i, a, b) for(int i = (a); i <= (b); ++i)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define sz(a) (int)(a).size()
#define all(a) (a).begin(), (a).end()
#define bit(s, i) (((s) >> (i)) & 1)
#define ii pair <int, int>
#define vii vector <ii>
#define vi vector <int>
#define fi first
#define se second
#define ll long long
#define eb emplace_back
#define pb push_back
#define __builtin_popcount __builtin_popcountll

void solve();

int32_t main() {
    if(fopen(task".inp", "r")) {
		freopen(task".inp", "r", stdin);
		freopen(task".out", "w", stdout);
	}
	cin.tie(0)->sync_with_stdio(0);

    int tc = 1; // cin >> tc;
    FOR(i, 1, tc) {
        solve();
    }
}

const int N = 1e5+5;

int n, m, p, tot_st[N], tot_en[N], num[N], low[N], ans[N], Time;
vector <pair <int, ii>> g[N], nwg[N];

void pre_dfs(int u, int id) {
    num[u] = low[u] = ++Time;
    for(pair <int, ii> i:g[u]) if(i.se.fi != id) {
        int v = i.fi;
        if(!num[v]) {
            nwg[u].eb(i);
            pre_dfs(v, i.se.fi);
            low[u] = min(low[u], low[v]);
            tot_st[u] += tot_st[v];
            tot_en[u] += tot_en[v];
        }
        else {
            low[u] = min(low[u], num[v]);
        }
    }
}

void dfs(int u) {
    for(pair <int, ii> i:nwg[u]) {
        int v = i.fi, id = i.se.fi, res = i.se.se;

        int out_st = tot_st[1] - tot_st[v],
            out_en = tot_en[1] - tot_en[v];

        if(low[v] == num[v]) {
            if(out_st > 0 && tot_en[v] > 0) ans[id] = res;
            else if(out_en > 0 && tot_st[v] > 0) ans[id] = res^1;
        }

        dfs(v);
    }
}

void solve() {
    cin >> n >> m;
    FOR(i, 1, m) {
        int x, y; cin >> x >> y;
        g[x].pb({y, {i, 0}}); g[y].pb({x, {i, 1}});
    }

    cin >> p;
    FOR(i, 1, p) {
        int x, y; cin >> x >> y;
        tot_st[x]++; tot_en[y]++;
    }

    memset(ans, -1, sizeof(ans));

    FOR(i, 1, n) if(!num[i]) {
        pre_dfs(1, 0);
        dfs(1);
    }

    FOR(i, 1, m) {
        if(ans[i] == -1) cout << 'B';
        if(ans[i] == 0) cout << 'R';
        if(ans[i] == 1) cout << 'L';
    }
}

Compilation message

oneway.cpp: In function 'int32_t main()':
oneway.cpp:25:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |   freopen(task".inp", "r", stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
oneway.cpp:26:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |   freopen(task".out", "w", stdout);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 5464 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 5464 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 5464 KB Output isn't correct
2 Halted 0 ms 0 KB -