Submission #1021852

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
10218522024-07-13 06:12:01vjudge1Paint By Numbers (IOI16_paint)C++17
90 / 100
8 ms6748 KiB
#include <bits/stdc++.h>
#define ent '\n'
typedef long long ll;
using namespace std;
const int maxn = 5e5+12;
int suff[maxn][103];
int pref[maxn][103];
int can[maxn];
int prefw[maxn];
int prefb[maxn];
int c[maxn];
int n, k;
string solve_puzzle(string s, vector<int> C){
n = s.size(), k = C.size();
for(int i=0;i<n;i++){
prefw[i+1] = prefw[i] + (s[i] == '_');
prefb[i+1] = prefb[i] + (s[i] == 'X');
c[i+1] = C[i];
}
string ans = "";
pref[0][0] = 1;
for(int i=1;i<=n;i++){
for(int j=0;j<=k;j++){
if(s[i-1] != 'X') pref[i][j] = pref[i-1][j];
if(j > 1 && i > c[j] && pref[i-c[j]-1][j-1] && prefw[i] == prefw[i-c[j]] && s[i - c[j] - 1] != 'X') {
pref[i][j] = 1;
}
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Compilation message (stderr)

paint.cpp: In function 'std::string solve_puzzle(std::string, std::vector<int>)':
paint.cpp:53:33: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   53 |                (l == 1 || l > 1 && s[l-2] != 'X') && (r == n || r < n && s[r] != 'X'))
      |                           ~~~~~~^~~~~~~~~~~~~~~~
paint.cpp:53:71: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   53 |                (l == 1 || l > 1 && s[l-2] != 'X') && (r == n || r < n && s[r] != 'X'))
      |                                                                 ~~~~~~^~~~~~~~~~~~~~
paint.cpp:61:14: warning: unused variable 'ok' [-Wunused-variable]
   61 |         bool ok = 0, fg = 0;
      |              ^~
#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...