# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
289118 |
2020-09-02T11:19:19 Z |
_7_7_ |
Toy Train (IOI17_train) |
C++14 |
|
136 ms |
1784 KB |
#include "train.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
//#define int long long
//#pragma GCC optimize("Ofast")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define fastio ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define all(x) x.begin(), x.end()
#define sz(s) (int)s.size()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define s second
#define f first
typedef pair < long long, long long > pll;
typedef pair < int, int > pii;
typedef unsigned long long ull;
typedef vector < pii > vpii;
typedef vector < int > vi;
typedef long double ldb;
typedef long long ll;
typedef double db;
typedef tree < int, null_type, less < int >, rb_tree_tag, tree_order_statistics_node_update > ordered_set;
const int inf = 1e9, maxn = 2e5 + 48, mod = 998244353, N = 5012;
const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1}, block = 300;
const pii base = mp(1171, 3307), Mod = mp(1e9 + 7, 1e9 + 9);
const db eps = 1e-12, pi = acos(-1);
const ll INF = 1e18;
int n, cnt[N], m, ok, a[N], r[N], v[N*5], u[N*5];
bool was[N], was1[N];
queue < int > q;
vi g[N], gr[N];
vi who_wins(vi A, vi R, vi U, vi V) {
n = sz(A);
m = sz(V);
for (int i = 0; i < n; ++i) {
a[i] = A[i];
r[i] = R[i];
}
for (int i = 0; i < m; ++i) {
v[i] = V[i];
u[i] = U[i];
}
for (int i = 0; i < m; ++i) {
g[u[i]].pb(v[i]);
gr[v[i]].pb(u[i]);
}
bool run;
do {
run = 0;
for (int i = 0; i < n; ++i) {
was1[i] = 0;
if (!was[i] && r[i]) {
q.push(i);
was1[i] = 1;
}
cnt[i] = !a[i] ? sz(g[i]) : 1;
}
while (sz(q)) {
int v = q.front();
q.pop();
for (auto to : gr[v]) {
--cnt[to];
if (!was[to] && !was1[to] && !cnt[to]) {
q.push(to);
was1[to] = 1;
}
}
}
for (int i = 0; i < n; ++i) {
if (!was1[i] && !was[i]) {
q.push(i);
was[i] = 1;
}
cnt[i] = a[i] ? sz(g[i]) : 1;
}
while (sz(q)) {
run = 1;
int v = q.front();
q.pop();
for (auto to : gr[v]) {
--cnt[to];
if (!was[to] && !cnt[to]) {
q.push(to);
was[to] = 1;
}
}
}
for (int i = 0; i < n; ++i)
if (!was[i])
for (int j = 0; j < sz(g[i]); ++j)
if (was[g[i][j]]) {
swap(g[i][j], g[i].back());
g[i].ppb();
--j;
}
} while (run);
vi ans;
for (int i = 0; i < n; ++i)
ans.pb(was[i]);
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
1280 KB |
3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
640 KB |
3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
136 ms |
1784 KB |
3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
9 ms |
1408 KB |
3rd lines differ - on the 1st token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
11 ms |
1664 KB |
3rd lines differ - on the 1st token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
1280 KB |
3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |