Submission #691482

#TimeUsernameProblemLanguageResultExecution timeMemory
691482NemanjaSo2005Paint By Numbers (IOI16_paint)C++14
Compilation error
0 ms0 KiB
#include<bits/stdc++.h>
#define ll long long
using namespace std;
string S;
int C[105],N,K;
int pbela[200005];
bool pref[200005][105],suf[200005][105],bela[200005];
void calcdp(){
   for(int i=1;i<=N;i++)
      bela[i]=(S[i]=='_');
   pbela[0]=0;
   for(int i=1;i<=N;i++)
      pbela[i]=pbela[i-1]+bela[i];
   pref[0][0]=1;
   suf[N+1][K]=1;
   for(int i=1;i<=N;i++){
      pref[i][0]=1;
      for(int j=1;j<=K;j++){
         if(i-C[j]<0)
            break;
         if(pbela[i]-pbela[i-C[j]]>0)
            continue;
         if(S[i-C[j]]=='X')
            continue;
         if(i-C[j]-1>=0)
            dp[i][j]=dp[i-C[j]-1][j-1];
         else
            dp[i][j]=1;
      }
      for(int j=1;j<=K;j++)
         if(pref[i-1][j]==1)
            pref[i][j]=1;
   }
   ///Suf[i][K] - Znaci da si postavio sve blokove iznad K, tj 0
   for(int i=N;i>=1;i--){
      suf[i][K]=1;
      for(int j=1;j<=K;j++){
         if(i-C[j]<0)
            break;
         if(pbela[i]-pbela[i-C[j]]>0)
            continue;
         if(S[i-C[j]]=='X')
            continue;
         if(i-C[j]-1>=0)
            dp[i][j]=dp[i-C[j]-1][j-1];
         else
            dp[i][j]=1;
      }
      for(int j=1;j<=K;j++)
         if(pref[i-1][j]==1)
            pref[i][j]=1;
   }
}
string solve_puzzle(string s, vector<int> c){
   N=s.size();
   K=c.size();
   for(int i=1;i<=K;i++)
      C[i]=c[i-1];
   S="."+s+".....";
   calcdp();
}



#include "paint.h"
#include <vector>
#include <string>
#include <cstdio>
#include <cassert>
const int S_MAX_LEN = 200 * 1000;
char buf[S_MAX_LEN + 1];
int main() {
    assert(1 == scanf("%s", buf));
    std::string s = buf;
    int c_len;
    assert(1 == scanf("%d", &c_len));
    std::vector<int> c(c_len);
    for (int i = 0; i < c_len; i++) {
        assert(1 == scanf("%d", &c[i]));
    }
    std::string ans = solve_puzzle(s, c);


    printf("%s\n", ans.data());
    return 0;
}

Compilation message (stderr)

paint.cpp: In function 'void calcdp()':
paint.cpp:26:13: error: 'dp' was not declared in this scope
   26 |             dp[i][j]=dp[i-C[j]-1][j-1];
      |             ^~
paint.cpp:28:13: error: 'dp' was not declared in this scope
   28 |             dp[i][j]=1;
      |             ^~
paint.cpp:45:13: error: 'dp' was not declared in this scope
   45 |             dp[i][j]=dp[i-C[j]-1][j-1];
      |             ^~
paint.cpp:47:13: error: 'dp' was not declared in this scope
   47 |             dp[i][j]=1;
      |             ^~
paint.cpp: In function 'std::string solve_puzzle(std::string, std::vector<int>)':
paint.cpp:61:1: warning: no return statement in function returning non-void [-Wreturn-type]
   61 | }
      | ^