Submission #863151

#TimeUsernameProblemLanguageResultExecution timeMemory
863151quandlmBinaria (CCO23_day1problem1)C++14
0 / 25
1 ms6612 KiB
#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 (stderr)

Main.cpp: In function 'int main()':
Main.cpp:2:60: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    2 | #define file(name)  if (fopen (name".inp", "r")) { freopen (name".inp", "r", stdin); freopen (name".out", "w", stdout); }
      |                                                    ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:45:5: note: in expansion of macro 'file'
   45 |     file("dynamic");
      |     ^~~~
Main.cpp:2:94: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    2 | #define file(name)  if (fopen (name".inp", "r")) { freopen (name".inp", "r", stdin); freopen (name".out", "w", stdout); }
      |                                                                                      ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:45:5: note: in expansion of macro 'file'
   45 |     file("dynamic");
      |     ^~~~
#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...