제출 #321513

#제출 시각아이디문제언어결과실행 시간메모리
321513KuuhakuPaint By Numbers (IOI16_paint)C++14
컴파일 에러
0 ms0 KiB
//Nov11-2020 #define tasknames "bblock" #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); } } string solve_puzzle(string s,vector<int> a) { Calc(k,n); int sum=0; string ans=""; for(int i=1;i<=n;i++) { sum+=ch_b[i]; if(sum>0&&ch_w[i]>0) ans+="?"; else { if(sum>0&&ch_w[i]==0) ans+="X"; else ans+="_"; } } return ans; } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); if(fopen(tasknames".INP","r")) { freopen(tasknames".INP","r",stdin); freopen(tasknames".OUT","w",stdout); } Enter(); cout<<solve_puzzle(s,c); }

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

paint.cpp: In function 'int main()':
paint.cpp:92:26: error: could not convert '(int*)(& c)' from 'int*' to 'std::vector<int>'
   92 |     cout<<solve_puzzle(s,c);
      |                          ^
      |                          |
      |                          int*
paint.cpp:88:13: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   88 |      freopen(tasknames".INP","r",stdin);
      |      ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
paint.cpp:89:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   89 |         freopen(tasknames".OUT","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~