제출 #102745

#제출 시각아이디문제언어결과실행 시간메모리
102745daniel920712Paint By Numbers (IOI16_paint)C++14
80 / 100
4 ms640 KiB
#include <iostream>
#include <stdio.h>
#include <vector>
#include "paint.h"
using namespace std;
int con[105]={0};
int Can[5][105]={0};
//int Canx[105]={0};
int N,M,ans=0;
bool have[105][105][5]={0};
int can[105][105][5]={0};
int F(int here,int what,int x,string &a,vector < int > &c)
{
    //printf("%d %d %d\n",here,what,x);
    int A,b,i;
    if(have[here][what][x]) return can[here][what][x];
    else if(here==N&&what==M) return 1;
    else if(here==N) return 0;
    else
    {
        if(x==0&&a[here]=='_'||x==1&&a[here]=='X') return 0;
        if(x==0)
        {
            if(here+c[what]>N) return 0;
            for(i=0;i<c[what];i++) if(a[i+here]=='_') return 0;

            have[here][what][x]=1;
            A=F(here+c[what],what+1,1,a,c);
            can[here][what][x]=A;
            if(A) for(i=0;i<c[what];i++) Can[0][i+here]=1;

        }
        else
        {
            have[here][what][x]=1;
            A=F(here+1,what,0,a,c);
            b=F(here+1,what,1,a,c);
            can[here][what][x]=A||b;
        }
    }
    Can[x][here]=can[here][what][x]||Can[x][here];
    return can[here][what][x];
}
string solve_puzzle(string s, vector < int > c)
{
    int i,j;
    N=s.length(),M=c.size();
    //printf("%d %d\n",N,M);
    //all[M]=0;
    //for(i=M-1;i>=0;i--) all[i]=all[i+1]+c[i]+1;
    F(0,0,0,s,c);
    F(0,0,1,s,c);
    for(i=0;i<N;i++)
    {
        if(Can[0][i]==0) s[i]='_';
        else if(Can[1][i]==0) s[i]='X';
        else s[i]='?';
    }
    return s;
}

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

paint.cpp: In function 'int F(int, int, int, std::__cxx11::string&, std::vector<int>&)':
paint.cpp:21:16: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
         if(x==0&&a[here]=='_'||x==1&&a[here]=='X') return 0;
            ~~~~^~~~~~~~~~~~~~
paint.cpp: In function 'std::__cxx11::string solve_puzzle(std::__cxx11::string, std::vector<int>)':
paint.cpp:46:11: warning: unused variable 'j' [-Wunused-variable]
     int i,j;
           ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...