# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
568029 | urosk | Paint By Numbers (IOI16_paint) | C++14 | 0 ms | 340 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "paint.h"
#define here cerr<<"===========================================\n"
#include <bits/stdc++.h>
#define ld double
#define ll int
#define ull unsigned long long
#define llinf 100000000000000000LL // 10^17
#define iinf 2000000000 // 2*10^9
#define pb push_back
#define popb pop_back
#define fi first
#define sc second
#define endl '\n'
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pld pair<ld,ld>
#define sz(a) int(a.size())
#define all(a) a.begin(),a.end()
#define ceri(a,l,r) {for(ll i_ = l;i_<=r;i_++) cerr<<a[i_]<< " ";cerr<<endl;}
using namespace std;
#define maxn 5005
#define maxk 105
ll n,k;
ll a[maxn];
ll p[maxn];
ll pb[maxn];
ll pw[maxn];
bool w[maxn];
bool b[maxn];
ll dp[maxn][maxk];
string solve_puzzle(string s,vector<int> c) {
n = sz(s);
k = sz(c);
ll cnt = 0;
ll cnt2 = 0;
for(ll i = 1;i<=n;i++) if(s[i-1]=='.') cnt++;
for(ll i = 1;i<=n;i++) if(s[i-1]=='_') cnt2++;
for(ll i = 1;i<=n;i++) pw[i] = pw[i-1] + (s[i-1]=='_');
if(cnt+cnt2==n){
for(ll i = 1;i<=k;i++) a[i] = c[i-1];
for(ll i = 1;i<=n;i++) p[i] = a[i] + p[i-1];
for(ll i = 1;i<=n;i++){
for(ll j = 0;j<=k;j++){
ll lid = i-1;
ll rid = i+1;
ll itl = j-1;
ll itr = j;
while(itl>=0&&lid>0){
//[lid-c[itl]+1,lid]
if(lid-c[itl]<=0) break;
if(pw[lid]-pw[lid-c[itl]]==0){
lid = lid-c[itl] - 1;
itl--;
}else itl--;
}
while(itr<=k-1&&rid<=n){
if(rid+c[itr]-1>n) break;
if(pw[rid+c[itr]-1]-pw[rid]==0){
rid = rid + c[itr] + 1;
itr++;
}else rid++;
}
if(itr==k&&itl==-1) w[i] = 1;
}
}
for(ll i = 1;i<=n;i++){
for(ll j = 1;j<=k;j++){
ll len = a[j];
ll lenl = p[j-1] + (j-1);
ll lenr = p[k] - p[j] + (k-j);
for(ll e = 1;e<=n;e++){
if(i<=e+len-1&&i>=e&&pw[e+len-1]-pw[e-1]==0){
ll lid = e-2;
ll rid = e+len+1;
ll itl = j-2;
ll itr = j;
while(itl>=0&&lid>0){
if(lid-c[itl]<0) break;
if(pw[lid]-pw[lid-c[itl]]==0){
lid = lid-c[itl] - 1;
itl--;
}else itl--;
}
while(itr<=k-1&&rid<=n){
if(rid+c[itr]-1>n) break;
if(pw[rid+c[itr]-1]-pw[rid]==0){
rid = rid + c[itr] + 1;
itr++;
}else rid++;
}
if(itr==k&&itl==-1){
b[i] = 1;
}
}
}
}
}
string ans;
for(ll i = 1;i<=n;i++){
if(s[i-1]!='.') ans.pb(s[i-1]);
else if(w[i]&&b[i]) ans.pb('?');
else if(w[i]) ans.pb('_');
else ans.pb('X');
}
return ans;
}
}
/*
........
2
3 4
..._._....
1
3
*/
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |