Submission #137192

#TimeUsernameProblemLanguageResultExecution timeMemory
137192mirbek01Paint By Numbers (IOI16_paint)C++11
Compilation error
0 ms0 KiB
#include "paint.h" #include "grader.cpp" #include <cstdlib> #include <bits/stdc++.h> using namespace std; const int N = 2e5 + 3; int pf[3][N], n, m; int dp[202][N], pref[N], f[202][N]; int get(int l, int r, int tp){ if(l > r) return 0; return pf[tp][r] - pf[tp][l - 1]; } int Get(int l, int r, int tp){ if(l > r) return 0; return f[tp][r] - f[tp][l - 1]; } string solve_puzzle(string s, vector<int> c) { n = (int)s.size(); m = (int)c.size(); s = ' ' + s; for(int i = 1; i <= n; i ++){ if(s[i] == 'X') pf[0][i] ++; if(s[i] == '_') pf[1][i] ++; if(s[i] == '.') pf[2][i] ++; pf[0][i] += pf[0][i - 1]; pf[1][i] += pf[1][i - 1]; pf[2][i] += pf[2][i - 1]; } for(int i = c[0]; i <= n; i ++){ if(get(i - c[0] + 1, i, 1) == 0 && get(1, i - c[0], 0) == 0 && (m != 1 || get(i + 1, n, 0) == 0)) dp[0][i] = 1; } for(int i = 1; i < m; i ++){ vector <int> pf(n + 1, 0), lastX(n + 1, 0); for(int j = 1; j <= n; j ++){ pf[j] = pf[j - 1] + dp[i - 1][j]; } for(int j = c[i] + 1; j <= n; j ++){ if(get(j - c[i] + 1, j, 1) == 0 && get(j - c[i], j - c[i], 0) == 0){ int sum = pf[j - c[i] - 1] - pf[lastX[j - c[i] - 1]]; if(sum && (i != m - 1 || get(j + 1, n, 0) == 0)) dp[i][j] = 1; } if(s[j] == 'X') lastX[j] = j; lastX[j] = max(lastX[j], lastX[j - 1]); } } int sum = c[m - 1]; for(int i = m - 2; i >= 0; i --){ vector <int> pf(n + 2, 0); for(int j = n; j >= 1; j --){ pf[j] = pf[j + 1] + dp[i + 1][j]; } for(int j = 1; j <= n; j ++){ if(dp[i][j] && (j + sum >= n || !pf[j + sum])) dp[i][j] = 0; } sum = c[i]; } for(int i = 0; i < m; i ++) for(int j = 1; j <= n; j ++) f[i][j] += f[i][j - 1] + dp[i][j]; string ans; for(int i = 1; i <= n; i ++){ if(s[i] == '.'){ int canX = 0, can_ = 0; for(int j = 0; j < m; j ++){ if(j == 0){ if(Get(i, n, 0)) can_ = 1; } else { if(Get(1, i - 1, j - 1) && Get(i + c[j] + 1, n, j)) can_ = 1; } if(Get(i, min(i + c[j], n), j)) canX = 1; } if(canX && can_) ans += '?'; else if(canX) ans += 'X'; else ans += '_'; } else ans += s[i]; } return ans; }

Compilation message (stderr)

/tmp/cc4n5UEB.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccP8VT80.o:paint.cpp:(.text.startup+0x0): first defined here
/tmp/cc4n5UEB.o:(.bss+0x0): multiple definition of `buf'
/tmp/ccP8VT80.o:(.bss+0x13748b60): first defined here
collect2: error: ld returned 1 exit status