Submission #790011

#TimeUsernameProblemLanguageResultExecution timeMemory
790011ymmToy Train (IOI17_train)C++17
0 / 100
772 ms7248 KiB
#include "train.h" #include <bits/stdc++.h> #define Loop(x,l,r) for (long long x = (l); x < (r); ++x) typedef long long ll; typedef std::pair<ll,ll> pll; using namespace std; const int N = 5032; bitset<N> berese[N], narese[N]; vector<int> A[N]; int col[N]; vector<int> chargs; int n, m; bool self[N]; std::vector<int> who_wins(std::vector<int> a, std::vector<int> r, std::vector<int> V, std::vector<int> U) { n = a.size(); m = V.size(); Loop (i,0,n) { col[i] = a[i]; if (r[i]) chargs.push_back(i); } Loop (i,0,m) { int v = V[i], u = U[i]; A[v].push_back(u); } Loop (i,0,n) narese[i].set(); Loop (i,0,n) { if (col[i]) { for (int j : A[i]) berese[i][j] = 1; } else { for (int j : A[i]) narese[i][j] = 0; } if (A[i].size() == 1) { berese[i][A[i][0]] = 1; narese[i][A[i][0]] = 0; } } Loop (i,0,n) { berese[i][i] = 1; narese[i][i] = 0; } // Loop (i,0,n) { // Loop (j,0,n) // cout << berese[i][j]; // cout << '\n'; // } // Loop (i,0,n) { // Loop (j,0,n) // cout << narese[i][j]; // cout << '\n'; // } // cout << '\n'; Loop (k,0,n) Loop (i,0,n) { if (!narese[i][k]) { berese[i] &= berese[k]; narese[i] &= narese[k]; } if (berese[i][k]) { berese[i] |= berese[k]; narese[i] |= narese[k]; } } // Loop (i,0,n) { // Loop (j,0,n) // cout << berese[i][j]; // cout << '\n'; // } // Loop (i,0,n) { // Loop (j,0,n) // cout << narese[i][j]; // cout << '\n'; // } // cout << '\n'; //} Loop (i,0,n) { self[i] = 1; Loop (j,0,n) self[i] &= narese[i][j] || berese[j][i]; } vector<int> fans(n); Loop (i,0,n) { bool ans = 0; for (int c : chargs) ans |= berese[i][c] && self[c]; fans[i] = ans; } return fans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...