# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
251498 |
2020-07-21T13:53:45 Z |
Vimmer |
Ili (COI17_ili) |
C++14 |
|
538 ms |
664 KB |
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("-O3")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("fast-math")
//#pragma GCC optimize("no-stack-protector")
#define F first
#define S second
#define sz(x) int(x.size())
#define pb push_back
#define pf push_front
#define N 100010
#define M ll(1e9 + 7)
#define inf 1e9 + 1e9
using namespace std;
//using namespace __gnu_pbds;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef short int si;
typedef array <ll, 3> a3;
typedef array <int, 4> a4;
typedef pair <int, ll> pt;
//typedef tree <int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
int n, m;
string s, t;
pair <int, int> from[N];
void go_bad(int v, bool f)
{
if (f) s[v] = '0'; else t[v] = '0';
if (v < m) {go_bad(from[v].F, f); go_bad(from[v].S, f);}
}
bool fnd(int v)
{
if (v >= m) return (s[v] == '1');
return fnd(from[v].F) | fnd(from[v].S);
}
int main()
{
//freopen("mining.in", "r", stdin); freopen("mining.out", "w", stdout);
ios_base::sync_with_stdio(0); istream::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> n >> m;
cin >> s;
for (int i = 0; i < n; i++) s += '1';
for (int i = 0; i < m; i++)
{
char c1, c2;
int x1, x2;
cin >> c1 >> x1 >> c2 >> x2;
x1--; x2--;
if (c1 == 'x') x1 += m;
if (c2 == 'x') x2 += m;
from[i] = {x1, x2};
}
for (int i = 0; i < m; i++)
if (s[i] == '0') go_bad(i, 1);
for (int i = 0; i < m; i++)
if (s[i] == '?')
{
if (!fnd(i)) {s[i] = '0'; continue;}
t = s;
go_bad(i, 0);
for (int j = 0; j < m; j++)
if (t[from[j].F] == '1' || t[from[j].S] == '1') t[j] = '1'; else t[j] = '0';
bool bad = 0;
for (int j = 0; j < m; j++)
if (s[j] == '1' && t[j] == '0') {bad = 1; break;}
if (bad) s[i] = '1';
}
for (int i = 0; i < m; i++) cout << s[i];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
6 |
Correct |
0 ms |
384 KB |
Output is correct |
7 |
Correct |
0 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
6 |
Correct |
0 ms |
384 KB |
Output is correct |
7 |
Correct |
0 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
2 ms |
384 KB |
Output is correct |
12 |
Correct |
1 ms |
384 KB |
Output is correct |
13 |
Correct |
1 ms |
384 KB |
Output is correct |
14 |
Correct |
2 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
6 |
Correct |
0 ms |
384 KB |
Output is correct |
7 |
Correct |
0 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
2 ms |
384 KB |
Output is correct |
12 |
Correct |
1 ms |
384 KB |
Output is correct |
13 |
Correct |
1 ms |
384 KB |
Output is correct |
14 |
Correct |
2 ms |
384 KB |
Output is correct |
15 |
Correct |
141 ms |
532 KB |
Output is correct |
16 |
Correct |
266 ms |
556 KB |
Output is correct |
17 |
Correct |
255 ms |
576 KB |
Output is correct |
18 |
Correct |
525 ms |
620 KB |
Output is correct |
19 |
Correct |
210 ms |
560 KB |
Output is correct |
20 |
Correct |
507 ms |
632 KB |
Output is correct |
21 |
Correct |
538 ms |
532 KB |
Output is correct |
22 |
Correct |
318 ms |
632 KB |
Output is correct |
23 |
Correct |
345 ms |
628 KB |
Output is correct |
24 |
Correct |
347 ms |
664 KB |
Output is correct |
25 |
Correct |
233 ms |
640 KB |
Output is correct |
26 |
Correct |
236 ms |
632 KB |
Output is correct |
27 |
Correct |
233 ms |
632 KB |
Output is correct |
28 |
Correct |
212 ms |
632 KB |
Output is correct |
29 |
Correct |
216 ms |
632 KB |
Output is correct |
30 |
Correct |
222 ms |
632 KB |
Output is correct |
31 |
Correct |
324 ms |
632 KB |
Output is correct |
32 |
Correct |
400 ms |
632 KB |
Output is correct |