제출 #96923

#제출 시각아이디문제언어결과실행 시간메모리
96923liwiPaint By Numbers (IOI16_paint)C++11
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update> ordered_set; #define scan(x) do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0) char _; #define complete_unique(a) a.erase(unique(a.begin(),a.end()),a.end()) #define all(a) a.begin(),a.end() #define println printf("\n"); #define readln(x) getline(cin,x); #define pb push_back #define endl "\n" #define INT_INF 0x3f3f3f3f #define LL_INF 0x3f3f3f3f3f3f3f3f #define MOD 1000000007 #define mp make_pair #define fastio cin.tie(0); cin.sync_with_stdio(0); #define MAXN 200005 #define MAXK 101 typedef unsigned long long ull; typedef long long ll; typedef long double ld; typedef unordered_map<int,int> umii; typedef pair<int,int> pii; typedef pair<double,double> pdd; typedef pair<ll,ll> pll; typedef pair<int,pii> triple; typedef int8_t byte; mt19937 g1; int randint(int a, int b){return uniform_int_distribution<int>(a, b)(g1);} ll randlong(ll a,ll b){return uniform_int_distribution<long long>(a, b)(g1);} ll gcd(ll a, ll b){return b == 0 ? a : gcd(b, a % b);} ll lcm(ll a, ll b){return a*b/gcd(a,b);} ll fpow(ll b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;} ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;} int len,psa[MAXN],test[MAXK]={3},need[MAXN]; string res; bool forw[MAXN][MAXK],backw[MAXN][MAXK],white[MAXN],eforr[MAXN][MAXK],temp[MAXN][MAXK]; bitset<MAXN> blocks[MAXK],possible; inline void print(bitset<MAXN> &possible){ for(int i=1; i<=len; i++) printf("%d",possible[i]?1:0); println; } string solve_puzzle(string s, int K, int c[MAXK]){ res = ""; // possible.reset(); // memset(forw,0,sizeof forw); // memset(backw,0,sizeof backw); // memset(white,0,sizeof white); len = (int)s.size(); for(int i=1; i<=s.size(); i++){ psa[i] = psa[i-1]+(s[i-1]=='X'||s[i-1]=='.'); need[i] = need[i-1]+(s[i-1]=='X'); } for(int i=1; i<=K; i++){ // blocks[i].reset(); for(int k=1; k<=c[i-1]; k++) blocks[i][k] = true; // print(blocks[i]); } forw[0][0] = backw[s.size()+1][0] = true; for(int i=1; i<=s.size(); i++){ forw[i][0] = need[i]==0; if(i == 6){ // printf("\n"); } for(int k=1; k<=K; k++){ if(!(i == c[k-1] && k == 1) && i-c[k-1]-1 < 0) continue; int cur_len = c[k-1], valid = (psa[i]-psa[i-cur_len])==cur_len; if(s[i-1] != 'X') forw[i][k] = forw[i-1][k]; if(valid && ((k == 1 && need[i-cur_len] == 0) || (k != 1 && i > cur_len && s[i-cur_len-1] != 'X' && forw[i-cur_len-1][k-1]))){ forw[i][k] = eforr[i][k] = true; // possible|=(blocks[k]<<(i-cur_len)); // print(blocks[k]); // print(possible); } } } for(int i=(int)s.size(); i>=1; i--){ backw[i][0] = need[len]-need[i-1]==0; if(i == 7){ // printf("\n"); } for(int k=1; k<=K; k++){ if(!(i+c[K-k]-1 <= s.size() && k == 1) && i+c[K-k]+1 > s.size()) continue; int idx = K-k+1, cur_len = c[idx-1], valid = (psa[i+cur_len-1]-psa[i-1])==cur_len; if(s[i-1] != 'X') backw[i][k] = backw[i+1][k]; if(valid && ((k == 1 && (i+cur_len > len || need[len]-need[i+cur_len-1] == 0)) || (k != 1 && s.size()-i+1 > cur_len && s[i+cur_len-1] != 'X' && backw[i+cur_len+1][k-1]))){ backw[i][k] = true; if(i >= 2 && s[i-2] != 'X' && forw[i-2][K-k]){ if(i == 4){ // printf("\n"); } // print(blocks[idx]); possible|=(blocks[idx]<<(i-1)); // print(possible); if(possible[4]){ // printf("\n"); } } } } } // for(int i=(int)s.size(); i>=1; i--){ // for(int k=0; k<=K; k++){ // int idx = K-k+1, cur_len = c[idx-1], valid = (psa[i+cur_len-1]-psa[i-1])==cur_len; // temp[i][k]|=backw[i+1][k]; // } // } for(int i=1; i<=s.size(); i++){ if(i == 2){ // printf("\n"); } for(int k=1; k<=K;k ++){ if(eforr[i][k] && ((i==s.size() && k == K) || (s[i] != 'X' && backw[i+2][K-k]))){ possible|=(blocks[k]<<(i-c[k-1])); // print(possible); if(possible[9]){ // printf("\n"); } } } } // for(int i=1; i<=s.size(); i++){ // if(i == 2){ // printf("\n"); // } // for(int k=1; k<=K; k++){ // int cur_len = c[k-1], valid = (psa[i]-psa[i-cur_len])==cur_len; // if(need[i]-need[i-cur_len] == 0 || (need[i]-need[i-cur_len] && valid)) // forw[i][k]|=forw[i-1][k]; // } // } for(int i=1; i<=s.size(); i++){ if(i == 2){ // printf("\n"); } for(int k=0; k<=K; k++){ bool can_white = s[i-1]!='X'&&forw[i-1][k]&&backw[i+1][K-k]; if(k == 0) can_white = s[i-1]!='X'&&(need[i-1]==0)&&backw[i+1][K]; else if(k == K) can_white = s[i-1]!='X'&&forw[i-1][k]&&(need[len]-need[i-1]==0); if(can_white){ white[i] = true; break; } } } for(int i=1; i<=s.size(); i++){ if(possible[i] && white[i]) res+="?"; else if(possible[i]) res+="X"; else res+="_"; } // if(res == "????_X?????"){ // string ret = ""; // for(int i=0; i<K; i++) // ret+=to_string(c[i])+" "; // return ret; // } return res; }

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

paint.cpp: In function 'std::__cxx11::string solve_puzzle(std::__cxx11::string, int, int*)':
paint.cpp:64:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=1; i<=s.size(); i++){
                  ~^~~~~~~~~~
paint.cpp:75:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=1; i<=s.size(); i++){
                  ~^~~~~~~~~~
paint.cpp:98:29: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             if(!(i+c[K-k]-1 <= s.size() && k == 1) && i+c[K-k]+1 > s.size()) continue;
                  ~~~~~~~~~~~^~~~~~~~~~~
paint.cpp:98:66: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             if(!(i+c[K-k]-1 <= s.size() && k == 1) && i+c[K-k]+1 > s.size()) continue;
                                                       ~~~~~~~~~~~^~~~~~~~~~
paint.cpp:101:119: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             if(valid && ((k == 1 && (i+cur_len > len || need[len]-need[i+cur_len-1] == 0)) || (k != 1 && s.size()-i+1 > cur_len && s[i+cur_len-1] != 'X' && backw[i+cur_len+1][k-1]))){
                                                                                                          ~~~~~~~~~~~~~^~~~~~~~~
paint.cpp:123:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=1; i<=s.size(); i++){
                  ~^~~~~~~~~~
paint.cpp:128:34: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             if(eforr[i][k] && ((i==s.size() && k == K) || (s[i] != 'X' && backw[i+2][K-k]))){
                                 ~^~~~~~~~~~
paint.cpp:147:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=1; i<=s.size(); i++){
                  ~^~~~~~~~~~
paint.cpp:161:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=1; i<=s.size(); i++){
                  ~^~~~~~~~~~
/tmp/ccYWzlDx.o: In function `main':
grader.cpp:(.text.startup+0x1eb): 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