Submission #1225562

#TimeUsernameProblemLanguageResultExecution timeMemory
1225562maya_sPaint By Numbers (IOI16_paint)C++20
80 / 100
336 ms4936 KiB
#include "paint.h" #include <bits/stdc++.h> using namespace std; typedef int ll; bool ok(ll n, ll k, string &s, vector<ll> &c){ vector<vector<vector<ll>>> dp(101, vector<vector<ll>>(101, vector<ll>(101))); if(s[0] != 'X') dp[0][0][0] = 1; if(s[0] != '_') dp[0][0][1] = 1; for(ll i = 1; i < n; i++){ for(ll b = 0; b < k; b++){ for(ll j = 0; j <= c[b]; j++){ if(j == 0 && s[i] != 'X') dp[i][b][j] = (dp[i-1][b][0] || (b ? dp[i-1][b-1][c[b-1]] : 0)); else if(j && s[i] != '_') dp[i][b][j] = dp[i-1][b][j-1]; } } } for(ll i = 0; i < n; i++) if(dp[i][k-1][c[k-1]]) { bool lol = 1; for(ll j = i+1; j < n; j++) { if(s[j] == 'X') lol = 0; } if(lol) return 1; } return 0; } string solve_puzzle(string s, vector<int> c) { ll n = s.size(), k = c.size(); string ans = s; for(ll i = 0; i < n; i++){ if(s[i] != '.') continue; s[i] = '_'; bool white = ok(n, k, s, c); s[i] = 'X'; bool black = ok(n, k, s, c); s[i] = '.'; if(!black) ans[i] = '_'; else if(!white) ans[i] = 'X'; else ans[i] = '?'; } return ans; }

Compilation message (stderr)

paint.h:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~
paint_c.h:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~
#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...