제출 #672519

#제출 시각아이디문제언어결과실행 시간메모리
672519Trisanu_DasPaint By Numbers (IOI16_paint)C++17
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h> #include "paint.h" using namespace std; string solve_puzzle(string s, vector<int> c) { int n = s.size(), k = c.size(); auto check=[&]{ int pref1[n + 1], pref2[n + 1]; for(int i = 0; i < n; i++){ pref1[i + 1] = pref1[i] + (s[i] == '_'); pref2[i + 1] = pref2[i] + (s[i] == 'X'); } int dp[k + 1][n + 1]; dp[0][0] = 1; for(int i = 0; i < k; i++){ for(int j = 0; j < n; j++){ if(j + 1 < c[i]) continue; for(int l = -1; l < j; l++){ if(l > j - c[i]) break; if((l >= 0 && l == j - c[i]) || (pref1[j + 1] - pref1[j + 1 - c[i]] > 0 || pref2[j + 1 - c[i]] - pref2[l + 1] > 0)) continue; dp[i + 1][j + 1] |= dp[i][l + 1]; } if(i + 1 == k && dp[i + 1][j + 1]) if(pref2[n] - pref2[j + 1] == 0) return true; } } return false; } string ans = s; for(int i = 0;i < n; i++){ if(s[i] == '_' || s[i] == 'X') continue; s[i] = '_'; int f1 = check(); s[i] = 'X'; int f2 = check(); s[i] = '.'; if(f1 && f2) ans[i]='?'; else if(f1) ans[i]='_'; else if(f2) ans[i]='X'; } return ans; }

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

paint.cpp: In function 'std::string solve_puzzle(std::string, std::vector<int>)':
paint.cpp:28:3: error: expected ',' or ';' before 'string'
   28 |   string ans = s;
      |   ^~~~~~
paint.cpp:36:16: error: 'ans' was not declared in this scope; did you mean 'abs'?
   36 |   if(f1 && f2) ans[i]='?';
      |                ^~~
      |                abs
paint.cpp:37:15: error: 'ans' was not declared in this scope; did you mean 'abs'?
   37 |   else if(f1) ans[i]='_';
      |               ^~~
      |               abs
paint.cpp:38:15: error: 'ans' was not declared in this scope; did you mean 'abs'?
   38 |   else if(f2) ans[i]='X';
      |               ^~~
      |               abs
paint.cpp:40:10: error: 'ans' was not declared in this scope; did you mean 'abs'?
   40 |   return ans;
      |          ^~~
      |          abs