Submission #321508

#TimeUsernameProblemLanguageResultExecution timeMemory
321508KuuhakuPaint By Numbers (IOI16_paint)C++14
Compilation error
0 ms0 KiB
//Nov11-2020
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;
const int maxn=2e5+2;
const int maxc=102;
int n, k, c[maxn], type[maxc][maxn], demw[maxn], ch_b[maxn], ch_w[maxn];
string s;
bool vs[maxc][maxn];

void Enter()
{
    cin>>s>>k;
    n=s.length();
    for(int i=1;i<=k;i++)
        cin>>c[i];
    s="."+s;
    for(int i=1;i<=n;i++)
    {
        demw[i]=demw[i-1];
        if(s[i]=='_')demw[i]++;
    }
    int j=0;
    while(j<=n&&s[j]!='X')
    {
        type[0][j]=2;
        j++;
    }
    for(int i=1;i<=k;i++)
        for(int j=1;j<=n;j++)
        {
            bool add_b=(j>=c[i]&&type[i-1][j-c[i]]>1&&demw[j]==demw[j-c[i]]) ? 1 : 0;
            bool add_w=(type[i][j-1]>0&&s[j]!='X') ? 1 : 0;
            if(add_b&&!add_w)type[i][j]=1;
            if(!add_b&&add_w)type[i][j]=2;
            if(add_b&&add_w)type[i][j]=3;
        }
}

void Calc(int i,int j)
{
    if(i<0||j<0)return;
    if(vs[i][j])return;
    vs[i][j]=true;
    if(type[i][j]==1||type[i][j]==3)
    {
        ch_b[j-c[i]+1]++;
        ch_b[j+1]--;
        ch_w[j-c[i]]++;
        Calc(i-1,j-c[i]-1);
    }
    if(type[i][j]==2||type[i][j]==3)
    {
        ch_w[j]++;
        Calc(i,j-1);
    }
}

void Solve()
{
    Calc(k,n);
    int sum=0;
    for(int i=1;i<=n;i++)
    {
        sum+=ch_b[i];
        if(sum>0&&ch_w[i]>0)
            cout<<"?";
        else
        {
            if(sum>0&&ch_w[i]==0)
                cout<<"X";
            else cout<<"_";
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    Enter();
    Solve();
}

Compilation message (stderr)

/tmp/cclHa2zO.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/cc7vjUjP.o:paint.cpp:(.text.startup+0x0): first defined here
/tmp/cclHa2zO.o: In function `main':
grader.cpp:(.text.startup+0x239): undefined reference to `solve_puzzle(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status