Submission #588408

#TimeUsernameProblemLanguageResultExecution timeMemory
588408Killer2501Vođe (COCI17_vode)C++14
120 / 120
1117 ms193004 KiB
#include <bits/stdc++.h> #define ll long long #define pb push_back #define task "deleg" #define pll pair<ll, ll> #define pii pair<ll, pll> #define fi first #define se second #define ull unsigned long long using namespace std; const ll mod = 1e15 + 7; const ll N = 5e3 + 5; const ll M = 1e6 + 5; vector<ll> adj[N], sub[N]; vector<ll> kq; int n, m, t, k, b[N], a[N], sum[N][N], dp[N][N]; string s[N]; pll p[N]; bool get1(int i, int l, int r) { return (sum[i][l] - sum[i][r+1] > 0); } bool get0(int i, int l, int r) { return (sum[i][l] - sum[i][r+1] < k); } void sol() { cin >> n >> m >> k; for(int i = 1; i <= n; i ++) { cin >> a[i]; dp[i][m-1] = 0; sum[i][m-1] = 0; } for(int j = m-2; j >= 0; j --) { for(int i = 1; i <= n; i ++) { int nxt = (i == n ? 1 : i+1); if(a[i] == a[nxt]) dp[i][j] = get1(nxt, j+1, min(j+k, m-1)); else dp[i][j] = get0(nxt, j+1, min(j+k, m-1)); } for(int i = 1; i <= n; i ++)sum[i][j] = sum[i][j+1]+dp[i][j]; } for(int i = 1; i <= n; i ++)cout << (a[i]^dp[i][0]^1) <<" "; } int main() { if (fopen(task ".in", "r")) { freopen(task ".in", "r", stdin); freopen(task ".out", "w", stdout); } ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int ntest = 1; // cin >> ntest; while (ntest-- > 0) sol(); }

Compilation message (stderr)

vode.cpp: In function 'int main()':
vode.cpp:54:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   54 |         freopen(task ".in", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
vode.cpp:55:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   55 |         freopen(task ".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...