Submission #823374

#TimeUsernameProblemLanguageResultExecution timeMemory
823374tolbiPaint By Numbers (IOI16_paint)C++17
100 / 100
281 ms27304 KiB
#pragma optimize("Bismillahirrahmanirrahim") //█▀█─█──█──█▀█─█─█ //█▄█─█──█──█▄█─█■█ //█─█─█▄─█▄─█─█─█─█ //ahmet23 orz... //FatihSultanMehmedHan(ortanca da orz) //AbdulhamidHan //YavuzSultanSelimHan #define author tolbi #include <bits/stdc++.h> using namespace std; template<typename X, typename Y> istream& operator>>(istream& is, pair<X,Y> &pr){return is>>pr.first>>pr.second;} template<typename X, typename Y> ostream& operator<<(ostream& os, pair<X,Y> pr){return os<<pr.first<<" "<<pr.second;} template<typename T> istream& operator>>(istream& is, vector<T> &arr){for (auto &it : arr) is>>it;return is;} template<typename T> ostream& operator<<(ostream& os, vector<T> arr){for (auto &it : arr) os<<it<<" ";return os;} template<typename T, size_t Y> istream& operator>>(istream& is, array<T,Y> &arr){for (auto &it : arr) is>>it;return is;} template<typename T, size_t Y> ostream& operator<<(ostream& os, array<T,Y> arr){for (auto &it : arr) os<<it<<" ";return os;} template<typename T> void coutarr(T __arr){for (auto &it : __arr){cout<<it<<" ";}cout<<endl;} #define deci(x) int x;cin>>x; #define decstr(x) string x;cin>>x; #define endl '\n' #define sortarr(x) sort(x.begin(), x.end()) #define sortrarr(x) sort(x.rbegin(), x.rend()) #define rev(x) reverse(x.begin(), x.end()) #define vint(x) vector<int> x #define tol(bi) (1LL<<((int64_t)(bi))) typedef long long ll; const int MOD = 1e9+7; mt19937 ayahya(chrono::high_resolution_clock().now().time_since_epoch().count()); #include "paint.h" #include <cstdlib> string s; int n,m; vector<int> c; vector<int> say1; vector<int> say2; vector<bitset<100>> dp; vector<bitset<100>> vis; vector<int> pref; vector<int> pref2; inline bool ava (int l, int r){ int hyd = 0; if (l) hyd=pref[l-1]; return (pref[r]==hyd); } inline bool arax (int l, int r){ int hyd = 0; if (l) hyd=pref2[l-1]; return (pref2[r]!=hyd); } bool f(int node, int flag){ if (flag>=m){ if (node>=n) return true; if (arax(node,n-1)) return false; if (node<=n-1){ say2[node]++; } return true; } if (node>=n) return false; if (vis[node][flag]) return dp[node][flag]; vis[node][flag]=1; dp[node][flag]=0; int l = node; int r = node+c[flag]-1; if (r>=n) return false; if (s[node]!='X' && f(node+1,flag)) { if (node<n) say2[node]++; if (node+1<n) say2[node+1]--; dp[node][flag]=1; } if (ava(l,r) && (r==n-1 || s[r+1]!='X') && f(r+2,flag+1)) { if (l<n) say1[l]++; if (r+1<n) say1[r+1]--; if (r+1<n) say2[r+1]++; if (r+2<n) say2[r+2]--; dp[node][flag]=1; } return dp[node][flag]; } string solve_puzzle(string _s, vector<int> _c) { s=_s; c=_c; n = s.length(); m = c.size(); dp.resize(n); say1.resize(n+1); say2.resize(n+1); vis.resize(n); string rval = s; pref.resize(n); pref2.resize(n); for (int i = 0; i < n; i++){ if (s[i]=='_') pref[i]=1; if (i) pref[i]+=pref[i-1]; if (s[i]=='X') pref2[i]=1; if (i) pref2[i]+=pref2[i-1]; } f(0,0); vector<int> ans(n,0); int cr1 = 0; int cr2 = 0; for (int i = 0; i < n; i++){ cr1+=say1[i]; cr2+=say2[i]; ans[i]|=(cr1>0); ans[i]|=(cr2>0)*2; rval[i]='?'; assert(ans[i]>0); if (ans[i]==1) rval[i]='X'; else if (ans[i]==2) rval[i]='_'; } return rval; }

Compilation message (stderr)

paint.cpp:1: warning: ignoring '#pragma optimize ' [-Wunknown-pragmas]
    1 | #pragma optimize("Bismillahirrahmanirrahim")
      |
#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...