제출 #619896

#제출 시각아이디문제언어결과실행 시간메모리
619896cfalasPaint By Numbers (IOI16_paint)C++17
32 / 100
11 ms820 KiB
#include "paint.h" #include<bits/stdc++.h> using namespace std; #define mp make_pair #define INF 10000000 #define MOD 1000000007 #define MID ((l+r)/2) #define HASHMOD 2305843009213693951 #define ll long long #define ull unsigned long long #define F first #define S second typedef pair<ll, ll> ii; typedef pair<ii, int> iii; typedef vector<int> vi; typedef vector<ii> vii; typedef map<int, int> mii; #define EPS 1e-6 #define FOR(i,n) for(int i=0;i<((int)(n));i++) #define FORi(i,a,b) for(int i=((int)(a));i<((int)(b));i++) #define FOA(v, a) for(auto v : a) #define len(x) ((int)x.size()) string solve_puzzle(string s, vector<int> c) { int n = len(s); int k = len(c); string dp[k][n]; //FOR(i,n) cout<<setw(n+2)<<i; cout<<endl; FOR(i,n){ if(i>=c[0]-1){ if(i==c[0]-1) FOR(j,c[0]) dp[0][i]+="X"; else dp[0][i] = "_" + dp[0][i-1]; } while(len(dp[0][i]) && len(dp[0][i])<n) dp[0][i]+="_"; while(len(dp[0][i])>n) dp[0][i].erase(dp[0][i].end()-1); //cout<<setw(n+2)<<dp[0][i]; } //cout<<endl; FORi(i,1,k){ FOR(j,n){ dp[i][j] = ""; if(j>c[i] && !dp[i-1][j-c[i]-1].empty()){ FOR(k,j+1) dp[i][j]+="Z"; FOR(k,c[i]) dp[i][j][j-k] = 'X'; dp[i][j][j-c[i]] = '_'; FOR(k,n-j-1) dp[i][j]+='_'; FOR(k,j-1){ if(k+1+c[i]>j) continue; if(dp[i-1][k].empty()) continue; FOR(m, j-c[i]){ if(dp[i][j][m]=='Z') dp[i][j][m] = dp[i-1][k][m]; else if(dp[i-1][k][m]!=dp[i][j][m]) dp[i][j][m] = '?'; } } } //cout<<setw(n+2)<<dp[i][j]; } //cout<<endl; } string ans = dp[k-1][n-1]; FOR(z,n){ if(dp[k-1][z].empty()) continue; FOR(m, n){ if(dp[k-1][z][m]!=ans[m]) ans[m] = '?'; //else cout<<m; } //cout<<setw(j+3)<<dp[i][j]; } return ans; }
#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...