Submission #579879

#TimeUsernameProblemLanguageResultExecution timeMemory
579879dxz05One-Way Streets (CEOI17_oneway)C++14
0 / 100
3028 ms23964 KiB
#pragma GCC optimize("Ofast,O2,O3,unroll-loops") #pragma GCC target("avx2") #include <bits/stdc++.h> #include <random> using namespace std; void debug_out() { cerr << endl; } template<typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << "[" << H << "]"; debug_out(T...); } #ifdef dddxxz #define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__) #else #define debug(...) 42 #endif #define SZ(s) ((int)s.size()) #define all(x) (x).begin(), (x).end() #define lla(x) (x).rbegin(), (x).rend() #define bpc(x) __builtin_popcount(x) #define bpcll(x) __builtin_popcountll(x) clock_t startTime; double getCurrentTime() { return (double) (clock() - startTime) / CLOCKS_PER_SEC; } #define MP make_pair typedef long long ll; mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count()); const double eps = 0.000001; const int MOD = 1e9 + 7; const int INF = 1000000101; const long long LLINF = 1223372000000000555; const int N = 1e6 + 3e2; const int M = 1111; int eu[N], ev[N]; vector<int> g[N]; int flag[N]; int blocked_x, blocked_y; bool used[N]; void dfs(int v){ used[v] = true; for (int u : g[v]){ if (v == blocked_x && u == blocked_y) continue; if (!used[u]) dfs(u); } } void solve(int TC) { int n, m; cin >> n >> m; map<pair<int, int>, int> mp; for (int i = 1; i <= m; i++){ int x, y; cin >> x >> y; eu[i] = x, ev[i] = y; if (x > y) swap(x, y); if (mp.find(MP(x, y)) != mp.end()){ flag[i] = flag[mp[MP(x, y)]] = 3; continue; } mp[MP(x, y)] = i; g[x].push_back(y); g[y].push_back(x); } int q; cin >> q; vector<pair<int, int>> important; while (q--){ int x, y; cin >> x >> y; important.emplace_back(x, y); } for (int i = 1; i <= m; i++){ if (flag[i] == 3) continue; bool left = true, right = true; for (auto now : important){ int x = now.first, y = now.second; blocked_x = eu[i]; blocked_y = ev[i]; fill(used + 1, used + n + 1, false); dfs(x); if (!used[y]) left = false; blocked_x = ev[i]; blocked_y = eu[i]; fill(used + 1, used + n + 1, false); dfs(x); if (!used[y]) right = false; } if (left) flag[i] |= 1; if (right) flag[i] |= 2; assert(flag[i] > 0); } for (int i = 1; i <= m; i++){ cout << (flag[i] == 1 ? 'L' : flag[i] == 2 ? 'R' : 'B'); } } int main() { startTime = clock(); ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); #ifdef dddxxz freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif int TC = 1; // cin >> TC; for (int test = 1; test <= TC; test++) { //debug(test); //cout << "Case #" << test << ": "; solve(test); } #ifdef dddxxz cerr << endl << "Time: " << int(getCurrentTime() * 1000) << " ms" << endl; #endif return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...