Submission #568027

#TimeUsernameProblemLanguageResultExecution timeMemory
568027uroskPaint By Numbers (IOI16_paint)C++14
32 / 100
3 ms340 KiB
#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){ 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 */

Compilation message (stderr)

paint.cpp: In function 'std::string solve_puzzle(std::string, std::vector<int>)':
paint.cpp:68:20: warning: unused variable 'lenl' [-Wunused-variable]
   68 |                 ll lenl = p[j-1] + (j-1);
      |                    ^~~~
paint.cpp:69:20: warning: unused variable 'lenr' [-Wunused-variable]
   69 |                 ll lenr = p[k] - p[j] + (k-j);
      |                    ^~~~
paint.cpp:106:1: warning: control reaches end of non-void function [-Wreturn-type]
  106 | }
      | ^
#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...