제출 #968652

#제출 시각아이디문제언어결과실행 시간메모리
968652MarwenElarbiPaint By Numbers (IOI16_paint)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include <cstdlib> using namespace std; int n,m; int pre[S_MAX_LEN]; int suf[S_MAX_LEN]; bool ok[S_MAX_LEN][105]; bool bad[S_MAX_LEN][5005]; bool vis[S_MAX_LEN][105]; bool dp[S_MAX_LEN][105]; vector<int> nabba(105); string bahma; bool dfs(int x,int y){ //cout <<n<<" "<<m<<endl; //cout <<x<<" "<<y<<" "<<vis[x][y]<<endl; if(x>n+1) return dp[x][y]=false; if(y==m){ if(x<=n){ //cout <<x<<endl; if(suf[n]-suf[x-1]>0) return false; bad[x][n-x]=true; } return dp[x][y]=true; } if(vis[x][y]) return dp[x][y]; vis[x][y]=true; //x++; if(bahma[x]!='X'&&dfs(x+1,y)){ bad[x][0]=true; } for (int i = x; i <= n-nabba[y]; ++i) { if(suf[i-1]-suf[x-1]>0) break; if((pre[i+nabba[y]-1]-pre[i-1])==0&&(suf[i+nabba[y]]-suf[i+nabba[y]-1])==0){ //cout <<suf[10+nabba[y]]-pre[10+nabba[y]-1]<<endl; dp[i][y]|=dfs(i+nabba[y]+1,y+1); dp[x][y]|=dp[i][y]; //dp[i][y]|=dfs(i+nabba[y],y+1); //if(x==10) cout <<i<<" "<<nabba[y]<<" "<<y<<" "<<dp[x][y]<<endl; if(dp[i][y]){ ok[i][y]=true; if(i-x>0) bad[x][i-x-1]=true; bad[i+nabba[y]][0]=true; //cout <<x<<" "<<i<<" "<<y<<endl; } //cout <<x<<" "<<i<<" "<<i+nabba[y]+1<<" "<<y+1<<endl; } } //cout <<"end "<<" "<<x<<" "<<y<<" "<<dp[x][y]<<endl; return dp[x][y]; } std::string solve_puzzle(std::string s, std::vector<int> c) { //if(s=="..._._....") return "???___????"; //if(s==".X........") return "?XX?______"; m=c.size(); nabba=c; s='#'+s; bahma=s; n=s.size(); //cout <<n<<endl; for (int i = 1; i <= n; ++i) { if(s[i]=='_') pre[i]=1; else if(s[i]=='X') suf[i]=1; pre[i]+=pre[i-1]; suf[i]+=suf[i-1]; } dfs(1,0); for (int i = 1; i <= n; ++i) { for (int j = 0; j < m; ++j) { if(ok[i][j]){ //cout <<i<<" "<<j<<endl; for (int k = i; k <= i+c[j]-1; ++k) { ok[k][104]=true; } } } } for (int i = 1; i <= n; ++i) { for (int j = 1; j <= n; ++j) { if(bad[i][j]){ for (int k = i; k <= i+j; ++k) { bad[k][0]=true; } } } } string res=""; for (int i = 1; i <= n; ++i) { //cout <<res<<endl; //cout <<ok[i][0]<<" "; if(s[i]!='.') res.push_back(s[i]); else if(ok[i][104]&&bad[i][0]) res.push_back('?'); else if(ok[i][104]) res.push_back('X'); else res.push_back('_'); } return res; }

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

paint.cpp:6:9: error: 'S_MAX_LEN' was not declared in this scope
    6 | int pre[S_MAX_LEN];
      |         ^~~~~~~~~
paint.cpp:7:9: error: 'S_MAX_LEN' was not declared in this scope
    7 | int suf[S_MAX_LEN];
      |         ^~~~~~~~~
paint.cpp:8:9: error: 'S_MAX_LEN' was not declared in this scope
    8 | bool ok[S_MAX_LEN][105];
      |         ^~~~~~~~~
paint.cpp:9:10: error: 'S_MAX_LEN' was not declared in this scope
    9 | bool bad[S_MAX_LEN][5005];
      |          ^~~~~~~~~
paint.cpp:10:10: error: 'S_MAX_LEN' was not declared in this scope
   10 | bool vis[S_MAX_LEN][105];
      |          ^~~~~~~~~
paint.cpp:11:9: error: 'S_MAX_LEN' was not declared in this scope
   11 | bool dp[S_MAX_LEN][105];
      |         ^~~~~~~~~
paint.cpp: In function 'bool dfs(int, int)':
paint.cpp:17:22: error: 'dp' was not declared in this scope
   17 |     if(x>n+1) return dp[x][y]=false;
      |                      ^~
paint.cpp:21:16: error: 'suf' was not declared in this scope
   21 |             if(suf[n]-suf[x-1]>0) return false;
      |                ^~~
paint.cpp:22:13: error: 'bad' was not declared in this scope
   22 |             bad[x][n-x]=true;
      |             ^~~
paint.cpp:24:16: error: 'dp' was not declared in this scope
   24 |         return dp[x][y]=true;
      |                ^~
paint.cpp:26:8: error: 'vis' was not declared in this scope
   26 |     if(vis[x][y]) return dp[x][y];
      |        ^~~
paint.cpp:26:26: error: 'dp' was not declared in this scope
   26 |     if(vis[x][y]) return dp[x][y];
      |                          ^~
paint.cpp:27:5: error: 'vis' was not declared in this scope
   27 |     vis[x][y]=true;
      |     ^~~
paint.cpp:30:9: error: 'bad' was not declared in this scope
   30 |         bad[x][0]=true;
      |         ^~~
paint.cpp:34:12: error: 'suf' was not declared in this scope
   34 |         if(suf[i-1]-suf[x-1]>0) break;
      |            ^~~
paint.cpp:35:13: error: 'pre' was not declared in this scope
   35 |         if((pre[i+nabba[y]-1]-pre[i-1])==0&&(suf[i+nabba[y]]-suf[i+nabba[y]-1])==0){
      |             ^~~
paint.cpp:35:46: error: 'suf' was not declared in this scope
   35 |         if((pre[i+nabba[y]-1]-pre[i-1])==0&&(suf[i+nabba[y]]-suf[i+nabba[y]-1])==0){
      |                                              ^~~
paint.cpp:37:13: error: 'dp' was not declared in this scope
   37 |             dp[i][y]|=dfs(i+nabba[y]+1,y+1);
      |             ^~
paint.cpp:42:17: error: 'ok' was not declared in this scope
   42 |                 ok[i][y]=true;
      |                 ^~
paint.cpp:43:27: error: 'bad' was not declared in this scope
   43 |                 if(i-x>0) bad[x][i-x-1]=true;
      |                           ^~~
paint.cpp:44:17: error: 'bad' was not declared in this scope
   44 |                 bad[i+nabba[y]][0]=true;
      |                 ^~~
paint.cpp:51:12: error: 'dp' was not declared in this scope
   51 |     return dp[x][y];
      |            ^~
paint.cpp: In function 'std::string solve_puzzle(std::string, std::vector<int>)':
paint.cpp:64:23: error: 'pre' was not declared in this scope
   64 |         if(s[i]=='_') pre[i]=1;
      |                       ^~~
paint.cpp:65:28: error: 'suf' was not declared in this scope
   65 |         else if(s[i]=='X') suf[i]=1;
      |                            ^~~
paint.cpp:66:9: error: 'pre' was not declared in this scope
   66 |         pre[i]+=pre[i-1];
      |         ^~~
paint.cpp:67:9: error: 'suf' was not declared in this scope
   67 |         suf[i]+=suf[i-1];
      |         ^~~
paint.cpp:74:16: error: 'ok' was not declared in this scope
   74 |             if(ok[i][j]){
      |                ^~
paint.cpp:87:16: error: 'bad' was not declared in this scope
   87 |             if(bad[i][j]){
      |                ^~~
paint.cpp:101:17: error: 'ok' was not declared in this scope
  101 |         else if(ok[i][104]&&bad[i][0]) res.push_back('?');
      |                 ^~
paint.cpp:101:29: error: 'bad' was not declared in this scope
  101 |         else if(ok[i][104]&&bad[i][0]) res.push_back('?');
      |                             ^~~