제출 #619941

#제출 시각아이디문제언어결과실행 시간메모리
619941cfalasPaint By Numbers (IOI16_paint)C++17
0 / 100
1 ms212 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){ FOR(j,n) dp[0][i]+='Z'; FOR(j,n) if(s[j]!='.') dp[0][i][j]=s[j]; bool ok = true; if(i>=c[0]-1){ FORi(j, i-c[0]+1, i+1){ if(dp[0][i][j]!='Z' && dp[0][i][j]!='X') ok=false; else dp[0][i][j] = 'X'; } } else ok = false; if(!ok) dp[0][i] = ""; //FOR(j,len(dp[0][i])) if(dp[0][i][j]=='Z') dp[0][i][j]='_'; //cout<<setw(n+2)<<dp[0][i]; } //cout<<endl; string ans; FORi(i,1,k){ FOR(j,n){ dp[i][j] = ""; bool ok = true; FORi(k, j-c[i]+1, j+1) if(s[j]!='.' && s[j]!='X') ok = false; if(j>c[i] && !dp[i-1][j-c[i]-1].empty() && ok){ 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]+='Z'; 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] = '?'; } } } if(len(dp[i][j])) ans = dp[i][j]; //cout<<setw(n+2)<<dp[i][j]; } //cout<<endl; } 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]; } FOR(i,n) if(ans[i]=='Z') ans[i]='_'; 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...