# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
863151 | 2023-10-19T17:04:47 Z | quandlm | Binaria (CCO23_day1problem1) | C++14 | 1 ms | 6612 KB |
#include <bits/stdc++.h> #define file(name) if (fopen (name".inp", "r")) { freopen (name".inp", "r", stdin); freopen (name".out", "w", stdout); } #define ll long long #define FOR(i, a, b) for (int i = (a); i <= (b); ++i) #define REP(i, a, b) for (int i = (a); i >= (b); --i) #define pi pair<int,int> #define ple tuple<int,int,int> #define fi first #define se second #define ii make_pair #define isz(a) ((int)a.size()) #define ALL(a) a.begin(), a.end() using namespace std; const int N = 1e6 + 10; const int mod = 1e6 + 3; int n,k,a[N],color[N],sz[N],lab[N]; void pre_calc () { FOR(i,1,n) { color[i] = -1; sz[i] = 1; lab[i] = i; } } int find (int u) { return (lab[u] == u ? u : lab[u] = find(lab[u])); } bool join (int u, int v) { u = find(u); v = find(v); if (u == v) return false; if (sz[u] < sz[v]) swap(u, v); lab[v] = u; sz[u] += sz[v]; if (color[v] == -1) color[v] = color[u]; return true; } int main () { file("dynamic"); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> k; FOR(i,1,n-k+1) cin >> a[i]; pre_calc(); FOR(i,1,n-k+1) { if(a[i] == a[i+1]) { join(i, i + k); } else if (a[i] > a[i+1]) { color[find(i)] = 1; color[find(i + k)] = 0; } else { color[find(i)] = 1; color[find(i + k)] = 0; } } int cnt = 0; FOR(i,1,k) { int c = color[find(i)]; if (c == -1) ++cnt; } int res = 1; FOR(i,1,cnt) res = 1ll * res * 2 % mod; res--; res %= mod; cout << res << '\n'; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 6492 KB | Output is correct |
2 | Incorrect | 1 ms | 6612 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 6492 KB | Output is correct |
2 | Incorrect | 1 ms | 6612 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 6492 KB | Output is correct |
2 | Incorrect | 1 ms | 6612 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 6492 KB | Output is correct |
2 | Incorrect | 1 ms | 6612 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 6492 KB | Output is correct |
2 | Incorrect | 1 ms | 6612 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 6492 KB | Output is correct |
2 | Incorrect | 1 ms | 6612 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |