Submission #236761

#TimeUsernameProblemLanguageResultExecution timeMemory
236761VEGAnnVođe (COCI17_vode)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #define sz(x) ((int)x.size()) #define ft first #define sd second using namespace std; typedef long long ll; const int N = 5010; const int oo = 2e9; const ll OO = 1e18; const int md = int(1e9) + 7; short fen[N][N], net[N], tp[N], n, m, k, pre[N][N], mem[N][N]; void upd(short id, short ps){ for (; ps < m; ps = (ps | (ps + 1))) fen[id][ps]++; } short sum(short id, short ps){ short res = 0; for (; ps >= 0; ps = (ps & (ps + 1)) - 1) res += fen[id][ps]; return res; } short get(short id, short vl){ if (pre[id][vl] == vl) return vl; else return (pre[id][vl] = get(id, pre[id][vl])); } short get(short ps, short vl){ if (mem[ps][vl] > 0) return mem[ps][vl] - 1; if (vl == m - 1) { mem[ps][vl] = 1; return 0; } short res = 0; short rt = min(vl + k, m - 1); while (1){ short nw = get(net[ps], pre[net[ps]][rt]); if (nw <= vl) break; mem[net[ps]][nw] = get(net[ps], nw) + 1; if (mem[net[ps]][nw] == 2) upd(net[ps], nw); pre[net[ps]][nw] = get(net[ps], pre[net[ps]][nw - 1]); } if (tp[net[ps]] == tp[ps]){ if (sum(net[ps], rt) - sum(net[ps], vl) > 0) res = 1; } else { if (sum(net[ps], rt) - sum(net[ps], vl) < rt - vl) res = 1; } mem[ps][vl] = res + 1; return res; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); #ifdef _LOCAL freopen("in.txt","r",stdin); #endif // _LOCAL cin >> n >> m >> k; k = min(m, k); for (short i = 0; i < n; i++) { cin >> tp[i]; net[i] = (i + 1) % n; for (short j = 0; j <= m; j++) pre[i][j] = j; } for (short i = 0; i < n; i++){ short ans = 0; ans = get(i, 0); cout << (tp[i] ^ ans ^ 1) << " "; } return 0; }

Compilation message (stderr)

vode.cpp: In function 'short int get(short int, short int)':
vode.cpp:31:7: error: redefinition of 'short int get(short int, short int)'
 short get(short ps, short vl){
       ^~~
vode.cpp:25:7: note: 'short int get(short int, short int)' previously defined here
 short get(short id, short vl){
       ^~~