제출 #108236

#제출 시각아이디문제언어결과실행 시간메모리
108236DodgeBallManPaint By Numbers (IOI16_paint)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include "paint.h" using namespace std; const int N - 2e5 + 10; int n, k, w[N], b[N], sum[N]; bool pre[N][110], suf[N][110], black[N], white[N]; vector<int> f(1); string solve_puzzle( string s, vector<int> f ) { n = s.length(), k = f.size(); s = '#' + s + '#'; for( int i : f ) c.emplace_back( i ); for( int i = 1 ; i <= n ; i++ ) { w[i] += w[i-1] + ( s[i] == '_' ); b[i] += b[i-1] + ( b[i] == 'X' ); } pre[0][0] = 1; for( int i = 1 ; i <= n ; i++ ) { pre[i][0] = ( b[i] == 0 ); for( int j = 1 ; j <= k ; j++ ) { if( s[i] != 'X' ) pre[i][j] |= pre[i-1][j]; if( s[i] != '_' && i >= c[j] && s[i-c[j]] != 'X' && w[i] == w[i-c[j]] ) { if( j == 1 ) pre[i][j] |= pre[i-c[j]][j-1]; else pre[i][j] |= pre[i-c[j]-1][j-1]; } } } suf[n+1][k+1] = suf[n+2][k+1] = 1; for( int i = n ; i >= 1 ; i-- ) { suf[n][k+1] = ( b[n] == b[i-1] ); for( int j = k ; j >= 1 ; j-- ) { if( s[i] != 'X' ) suf[i][j] |= suf[i+1][j]; if( s[i] != '_' && i + c[j] <= n + 1 && s[i+c[j]] != 'X' && w[i-1] == w[i+c[j]-1] ) suf[i][j] |= suf[i+c[j]+1][j+1]; } } for( int i = 1 ; i <= n ; i++ ) { if( s[i] == '_' ) white[i] = 1; else for( int j = 0 ; j <= k ; j++ ) white[i] |= ( pre[i-1][j] && suf[i+1][j+1] ); if( s[i] == '_' ) continue; for( int j = 1 ; j <= k ; j++ ) if( i >= c[j] && s[i-c[j]] != 'X' && s[i+1] != 'X' && w[i] == w[i-c[j]] ) { if( !suf[i+2][j+1] ) continue; if( ( j == 1 && pre[i-c[j]][j-1] ) || ( i > c[j] && pre[i-c[j-1]][j-1] ) ) sum[i-c[j]+1]++, sum[i+1]--; } } string ans = ""; for( int i = 1 ; i <= n ; i++ ) { sum[i] += sum[i-1]; black[i] = ( sum[i] > 0 ); if( s[i] != '.' ) ans += s[i]; else if( black[i] && white[i] ) ans += '?'; else ans += black[i] ? 'X' : '_'; } return ans; }

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

paint.cpp:6:13: error: expected initializer before '-' token
 const int N - 2e5 + 10;
             ^
paint.cpp:8:13: error: 'N' was not declared in this scope
 int n, k, w[N], b[N], sum[N];
             ^
paint.cpp:8:19: error: 'N' was not declared in this scope
 int n, k, w[N], b[N], sum[N];
                   ^
paint.cpp:8:27: error: 'N' was not declared in this scope
 int n, k, w[N], b[N], sum[N];
                           ^
paint.cpp:9:10: error: 'N' was not declared in this scope
 bool pre[N][110], suf[N][110], black[N], white[N];
          ^
paint.cpp:9:23: error: 'N' was not declared in this scope
 bool pre[N][110], suf[N][110], black[N], white[N];
                       ^
paint.cpp:9:38: error: 'N' was not declared in this scope
 bool pre[N][110], suf[N][110], black[N], white[N];
                                      ^
paint.cpp:9:48: error: 'N' was not declared in this scope
 bool pre[N][110], suf[N][110], black[N], white[N];
                                                ^
paint.cpp: In function 'std::__cxx11::string solve_puzzle(std::__cxx11::string, std::vector<int>)':
paint.cpp:15:22: error: 'c' was not declared in this scope
     for( int i : f ) c.emplace_back( i );
                      ^
paint.cpp:17:9: error: 'w' was not declared in this scope
         w[i] += w[i-1] + ( s[i] == '_' );
         ^
paint.cpp:18:9: error: 'b' was not declared in this scope
         b[i] += b[i-1] + ( b[i] == 'X' );
         ^
paint.cpp:20:5: error: 'pre' was not declared in this scope
     pre[0][0] = 1;
     ^~~
paint.cpp:20:5: note: suggested alternative: 'drem'
     pre[0][0] = 1;
     ^~~
     drem
paint.cpp:22:23: error: 'b' was not declared in this scope
         pre[i][0] = ( b[i] == 0 );
                       ^
paint.cpp:25:37: error: 'c' was not declared in this scope
             if( s[i] != '_' && i >= c[j] && s[i-c[j]] != 'X' && w[i] == w[i-c[j]] ) {
                                     ^
paint.cpp:25:65: error: 'w' was not declared in this scope
             if( s[i] != '_' && i >= c[j] && s[i-c[j]] != 'X' && w[i] == w[i-c[j]] ) {
                                                                 ^
paint.cpp:31:5: error: 'suf' was not declared in this scope
     suf[n+1][k+1] = suf[n+2][k+1] = 1;
     ^~~
paint.cpp:33:25: error: 'b' was not declared in this scope
         suf[n][k+1] = ( b[n] == b[i-1] );
                         ^
paint.cpp:36:36: error: 'c' was not declared in this scope
             if( s[i] != '_' && i + c[j] <= n + 1 && s[i+c[j]] != 'X' && w[i-1] == w[i+c[j]-1] )
                                    ^
paint.cpp:36:73: error: 'w' was not declared in this scope
             if( s[i] != '_' && i + c[j] <= n + 1 && s[i+c[j]] != 'X' && w[i-1] == w[i+c[j]-1] )
                                                                         ^
paint.cpp:41:27: error: 'white' was not declared in this scope
         if( s[i] == '_' ) white[i] = 1;
                           ^~~~~
paint.cpp:41:27: note: suggested alternative: 'wait'
         if( s[i] == '_' ) white[i] = 1;
                           ^~~~~
                           wait
paint.cpp:43:17: error: 'white' was not declared in this scope
                 white[i] |= ( pre[i-1][j] && suf[i+1][j+1] );
                 ^~~~~
paint.cpp:43:17: note: suggested alternative: 'wait'
                 white[i] |= ( pre[i-1][j] && suf[i+1][j+1] );
                 ^~~~~
                 wait
paint.cpp:45:50: error: 'c' was not declared in this scope
         for( int j = 1 ; j <= k ; j++ ) if( i >= c[j] && s[i-c[j]] != 'X' && s[i+1] != 'X' && w[i] == w[i-c[j]] ) {
                                                  ^
paint.cpp:45:95: error: 'w' was not declared in this scope
         for( int j = 1 ; j <= k ; j++ ) if( i >= c[j] && s[i-c[j]] != 'X' && s[i+1] != 'X' && w[i] == w[i-c[j]] ) {
                                                                                               ^
paint.cpp:48:17: error: 'sum' was not declared in this scope
                 sum[i-c[j]+1]++, sum[i+1]--;
                 ^~~
paint.cpp:53:9: error: 'sum' was not declared in this scope
         sum[i] += sum[i-1];
         ^~~
paint.cpp:54:9: error: 'black' was not declared in this scope
         black[i] = ( sum[i] > 0 );
         ^~~~~
paint.cpp:54:9: note: suggested alternative: 'clock'
         black[i] = ( sum[i] > 0 );
         ^~~~~
         clock
paint.cpp:56:30: error: 'white' was not declared in this scope
         else if( black[i] && white[i] ) ans += '?';
                              ^~~~~
paint.cpp:56:30: note: suggested alternative: 'wait'
         else if( black[i] && white[i] ) ans += '?';
                              ^~~~~
                              wait