Submission #938405

# Submission time Handle Problem Language Result Execution time Memory
938405 2024-03-05T06:00:46 Z vjudge1 One-Way Streets (CEOI17_oneway) C++17
0 / 100
2 ms 3828 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) x.begin(), x.end()
#define size(x) (int)x.size()

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;
}
const int N = 1e5 + 1;

vector<vector<int>> g(N);
bool vis[N];
int parent[N];

void dfs(int v) {
	vis[v] = true;
	for (int to : g[v]) {
		if (!vis[to]) {
			parent[to] = v;
			dfs(to);
		}
	}
}

signed main() {
	cin.tie(nullptr)->sync_with_stdio(false);
	int n, m; cin >> n >> m;
	int a[m], b[m];
	for (int i = 0; i < m; ++i) {
		cin >> a[i] >> b[i];
		g[a[i]].push_back(b[i]);
		g[b[i]].push_back(a[i]);
	}
	int p; cin >> p;
	int u[p], v[p];
	map<pair<int, int>, bool> used;
	for (int i = 0; i < p; ++i) {
		cin >> u[i] >> v[i];
		dfs(u[i]);
		vector<int> path;
		//int x = v[i];
		//while (x) {
			//path.push_back(x);
			//x = parent[x];
		//}
		reverse(all(path));
		for (int i = 1; i < size(path); ++i) {
			used[{path[i - 1], path[i]}] = true;
			g[path[i]].erase(find(all(g[path[i]]), path[i - 1]));
		}
		memset(vis, false, sizeof(vis));
		memset(parent, 0, sizeof(parent));
	}
	for (int i = 0; i < m; ++i) {
		if (used[{a[i], b[i]}]) {
			cout << 'R';
		} else if (used[{b[i], a[i]}]) {
			cout << 'L';
		} else {
			cout << 'B';
		}
	}
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 3828 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 3828 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 3828 KB Output isn't correct
2 Halted 0 ms 0 KB -