제출 #1118889

#제출 시각아이디문제언어결과실행 시간메모리
1118889epicci23Paint By Numbers (IOI16_paint)C++17
컴파일 에러
0 ms0 KiB
#include "bits/stdc++.h" //#define int long long #define all(v) v.begin() , v.end() #define sz(a) (int)a.size() using namespace std; const int K = 105; string solve_puzzle(string s,vector<int> c){ int n = sz(s),k = sz(c); s = " " + s; vector<int> v(k+5); for(int i=1;i<=k;i++) v[i] = c[i]; vector<int> sumi(n+5,0); for(int i=1;i<=n;i++) sumi[i] = sumi[i-1] + (s[i]=='_'); auto Not = [&](int ind) -> bool{ if(ind<1 || ind>n) return 1; return s[ind] != 'X'; }; auto is_val = [&](int l,int r) -> bool{ if(l<1 || r>n || l>r) return 0; return (sumi[r] - sumi[l - 1] == 0); }; bitset<K> pre[n+5],suf[n+5]; pre[0][0] = suf[k+1][n+1] = suf[k+1][n+2] = 1; for(int i=1;i<=n;i++){ pre[0][i] = pre[0][i-1]; if(s[i] == 'X') pre[0][i] = 0; } for(int i=n;i>=1;i--){ suf[k+1][i] = suf[k+1][i+1]; if(s[i] == 'X') suf[k+1][i] = 0; } for(int i=1;i<=n;i++){ for(int j=1;j<=k;j++){ if(pre[j][i-1] && Not(i)) pre[j][i]=1; if(is_val(i-v[j]+1,i) && (i-v[j] > 0 ? pre[j-1][i-v[j]-1] : (j == 1)) && Not(i+1) && Not(i-v[j])) pre[j][i]=1; } } for(int i=n;i>=1;i--){ for(int j=k;j>=1;j--){ if(suf[j][i+1] && Not(i)) suf[j][i]=1; if(is_val(i,i+v[j]-1) && suf[j+1][i+v[j]+1] && Not(i-1) && Not(i+v[j])) suf[j][i]=1; } } vector<int> ans1(n+5,0),ans2(n+5,0); for(int i=1;i<=n;i++){ int lol=0; for(int j=0;j<=k;j++) if(pre[j][i-1] && suf[j+1][i+1]) lol = 1; ans1[i] = lol; } for(int i=1;i<=n;i++){ for(int j=1;j<=k;j++){ if(is_val(i,i+v[j]-1) && Not(i-1) && Not(i+v[j]) && (i>=2 ? pre[j-1][i-2] : (j == 1)) && suf[j+1][i+v[j]+1]){ ans2[i]++; ans2[i+v[j]]--; } } } for(int i=1;i<=n;i++) ans2[i]+=ans2[i-1]; string res=""; for(int i=1;i<=n;i++){ if(s[i]!='.') res.push_back(s[i]); else if(ans1[i] && ans2[i]) res.push_back('?'); else if(ans1[i]) res.push_back('_'); else res.push_back('X'); } return res; } /*void _(){ int n,k; string s; cin >> s; n = sz(s); s = " " + s; cin >> k; vector<int> v(k+5); for(int i=1;i<=k;i++) cin >> v[i]; int sumi[n+5]; sumi[0] = 0; for(int i=1;i<=n;i++) sumi[i] = sumi[i-1] + (s[i]=='_'); auto Not = [&](int ind) -> bool{ if(ind<1 || ind>n) return 1; return s[ind] != 'X'; }; auto is_val = [&](int l,int r) -> bool{ if(l<1 || r>n || l>r) return 0; return (sumi[r] - sumi[l - 1] == 0); }; bitset<K> pre[n+5],suf[n+5]; pre[0][0] = suf[k+1][n+1] = suf[k+1][n+2] = 1; for(int i=1;i<=n;i++){ pre[0][i] = pre[0][i-1]; if(s[i] == 'X') pre[0][i] = 0; } for(int i=n;i>=1;i--){ suf[k+1][i] = suf[k+1][i+1]; if(s[i] == 'X') suf[k+1][i] = 0; } for(int i=1;i<=n;i++){ for(int j=1;j<=k;j++){ if(pre[j][i-1] && Not(i)) pre[j][i]=1; if(is_val(i-v[j]+1,i) && (i-v[j] > 0 ? pre[j-1][i-v[j]-1] : (j == 1)) && Not(i+1) && Not(i-v[j])) pre[j][i]=1; } } for(int i=n;i>=1;i--){ for(int j=k;j>=1;j--){ if(suf[j][i+1] && Not(i)) suf[j][i]=1; if(is_val(i,i+v[j]-1) && suf[j+1][i+v[j]+1] && Not(i-1) && Not(i+v[j])) suf[j][i]=1; } } vector<int> ans1(n+5,0),ans2(n+5,0); for(int i=1;i<=n;i++){ int lol=0; for(int j=0;j<=k;j++) if(pre[j][i-1] && suf[j+1][i+1]) lol = 1; ans1[i] = lol; } for(int i=1;i<=n;i++){ for(int j=1;j<=k;j++){ if(is_val(i,i+v[j]-1) && Not(i-1) && Not(i+v[j]) && (i>=2 ? pre[j-1][i-2] : (j == 1)) && suf[j+1][i+v[j]+1]){ ans2[i]++; ans2[i+v[j]]--; } } } for(int i=1;i<=n;i++) ans2[i]+=ans2[i-1]; for(int i=1;i<=n;i++){ if(s[i]!='.') cout << s[i]; else if(ans1[i] && ans2[i]) cout << '?'; else if(ans1[i]) cout << '_'; else cout << 'X'; } cout << '\n'; } int32_t main(){ cin.tie(0); ios::sync_with_stdio(0); int tc=1;//cin >> tc; while(tc--) _(); return 0; }

컴파일 시 표준 에러 (stderr) 메시지

paint.cpp:86:1: error: unterminated comment
   86 | /*void _(){
      | ^