Submission #367130

#TimeUsernameProblemLanguageResultExecution timeMemory
367130uacoder123Paint By Numbers (IOI16_paint)C++14
Compilation error
0 ms0 KiB
#include "paint.h" #include <cstdlib> int dp[2*10010][100],dp1[2*10010][100],pw[2*10010]; std::string solve_puzzle(std::string s, std::vector<int> c) { c.pb(0); c.insert(c.begin(),0); string s1=s; s=" "+s; int n=s.size()-2,k=c.size(); for(int i=0;i<n;++i) s1[i]='?'; for(int i=2;i<=n+1;++i) { pw[i]=pw[i-1]; if(s[i]=='_') pw[i]++; } for(int i=0;i<k;++i) { if(i==k-1) dp[n+3][i]=1; else dp[n+3][i]=0; if(i==k-1) dp[n+2][i]=1; else dp[n+2][i]=0; if(i==0) dp1[0][i]=1; else dp1[0][i]=0; if(i==0) dp1[1][i]=1; else dp1[1][i]=0; } for(int i=n+1;i>=2;--i) { for(int j=k-1;j>=0;--j) { if(j==0) { dp[i][j]=dp[i][j+1]; continue; } if(s[i]!='X') dp[i][j]=dp[i+1][j]; if(s[i]!='_'&&c[j]>0) { if(i+c[j]-1<=n+1&&pw[i+c[j]-1]-pw[i-1]==0&&(i+c[j]>n+1||s[i+c[j]]!='X')) dp[i][j]=max(dp[i][j],dp[i+c[j]+1][j+1]); } } } for(int i=2;i<=n+1;++i) { for(int j=0;j<k;++j) { if(j==k-1) { dp1[i][j]=dp1[i][j-1]; continue; } if(s[i]!='X') dp1[i][j]=dp1[i-1][j]; if(s[i]!='X'&&c[j]>0) { if(i-(c[j]-1)>=2&&pw[i]-pw[i-(c[j]-1)-1]==0&&(i-(c[j]-1)-1<2||s[i-(c[j]-1)-1]!='X')) dp1[i][j]=max(dp1[i][j],dp1[i-(c[j]-1)-2][j-1]); } } } int re=0; for(int i=2;i<=n+1;++i) { int fl=0,fl1=0; for(int j=1;j<k;++j) { if(s[i]!='X'&&dp[i+1][j]+dp1[i-1][j-1]==2) fl=1; int in=i+c[j]-1; if(s[i]!='_'&&j!=k-1&&in<=n+1&&pw[in]-pw[i-1]==0&&s[i-1]!='X'&&(in+1>n+1||s[in+1]!='X')) { if(dp1[i-2][j-1]+dp[in+2][j+1]==2) { fl1=1; re=max(re,c[j]); } } } if(re>0) { fl1=1; re--; } if(fl+fl1==2) continue; if(fl) s1[i-2]='_'; else s1[i-2]='X'; } return s1; }

Compilation message (stderr)

paint.cpp: In function 'std::string solve_puzzle(std::string, std::vector<int>)':
paint.cpp:7:7: error: 'class std::vector<int>' has no member named 'pb'
    7 |     c.pb(0);
      |       ^~
paint.cpp:9:5: error: 'string' was not declared in this scope; did you mean 'std::string'?
    9 |     string s1=s;
      |     ^~~~~~
      |     std::string
In file included from /usr/include/c++/9/string:39,
                 from paint.h:3,
                 from paint.cpp:1:
/usr/include/c++/9/bits/stringfwd.h:79:33: note: 'std::string' declared here
   79 |   typedef basic_string<char>    string;
      |                                 ^~~~~~
paint.cpp:13:9: error: 's1' was not declared in this scope; did you mean 's'?
   13 |         s1[i]='?';
      |         ^~
      |         s
paint.cpp:53:30: error: 'max' was not declared in this scope; did you mean 'std::max'?
   53 |                     dp[i][j]=max(dp[i][j],dp[i+c[j]+1][j+1]);
      |                              ^~~
      |                              std::max
In file included from /usr/include/c++/9/bits/char_traits.h:39,
                 from /usr/include/c++/9/string:40,
                 from paint.h:3,
                 from paint.cpp:1:
/usr/include/c++/9/bits/stl_algobase.h:268:5: note: 'std::max' declared here
  268 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
paint.cpp:71:31: error: 'max' was not declared in this scope; did you mean 'std::max'?
   71 |                     dp1[i][j]=max(dp1[i][j],dp1[i-(c[j]-1)-2][j-1]);
      |                               ^~~
      |                               std::max
In file included from /usr/include/c++/9/bits/char_traits.h:39,
                 from /usr/include/c++/9/string:40,
                 from paint.h:3,
                 from paint.cpp:1:
/usr/include/c++/9/bits/stl_algobase.h:268:5: note: 'std::max' declared here
  268 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
paint.cpp:89:24: error: 'max' was not declared in this scope; did you mean 'std::max'?
   89 |                     re=max(re,c[j]);
      |                        ^~~
      |                        std::max
In file included from /usr/include/c++/9/bits/char_traits.h:39,
                 from /usr/include/c++/9/string:40,
                 from paint.h:3,
                 from paint.cpp:1:
/usr/include/c++/9/bits/stl_algobase.h:268:5: note: 'std::max' declared here
  268 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
paint.cpp:101:13: error: 's1' was not declared in this scope; did you mean 's'?
  101 |             s1[i-2]='_';
      |             ^~
      |             s
paint.cpp:103:13: error: 's1' was not declared in this scope; did you mean 's'?
  103 |             s1[i-2]='X';
      |             ^~
      |             s
paint.cpp:106:12: error: 's1' was not declared in this scope; did you mean 's'?
  106 |     return s1;
      |            ^~
      |            s