제출 #966997

#제출 시각아이디문제언어결과실행 시간메모리
966997MarwenElarbiPaint By Numbers (IOI16_paint)C++17
컴파일 에러
0 ms0 KiB
//#pragma once //#include "paint.h" #include <bits/stdc++.h> #include <cstdlib> using namespace std; const int S_MAX_LEN = 5005; char buf[S_MAX_LEN + 1]; int n,m; int pre[S_MAX_LEN]; int suf[S_MAX_LEN]; bool ok[S_MAX_LEN][105]; bool bad[S_MAX_LEN][5005]; bool vis[S_MAX_LEN][105]; bool dp[S_MAX_LEN][105]; vector<int> nabba(105); string bahma; bool dfs(int x,int y){ //cout <<n<<" "<<m<<endl; //cout <<x<<" "<<y<<" "<<vis[x][y]<<endl; if(x>n) return dp[x][y]=false; if(y==m){ if(x<n){ //cout <<x<<endl; bad[x][n-x+1]=true; } return dp[x][y]=true; } if(vis[x][y]) return dp[x][y]; vis[x][y]=true; x++; if(bahma[x]!='X'&&dfs(x,y)){ bad[x][0]=true; } for (int i = x; i <= n-nabba[y]; ++i) { if(suf[i-1]-suf[x-1]>0) break; if((pre[i+nabba[y]-1]-pre[i-1])==0&&(suf[i+nabba[y]]-suf[i+nabba[y]-1])==0){ //cout <<x<<" "<<i+nabba[y]<<" "<<y<<endl; dp[x][y]|=dfs(i+nabba[y],y+1); if(dp[i][y]){ ok[i][y]=true; if(i-x>0) bad[x][i-x-1]=true; bad[i+nabba[y]][0]=true; //cout <<x<<" "<<i<<" "<<y<<endl; } //cout <<x<<" "<<i<<" "<<i+nabba[y]+1<<" "<<y+1<<endl; } } //cout <<"end "<<x<<" "<<y<<" "<<dp[x][y]<<endl; return dp[x][y]; } std::string solve_puzzle(std::string s, std::vector<int> c) { //if(s=="..._._....") return "???___????"; //if(s==".X........") return "?XX?______"; m=c.size(); nabba=c; s='#'+s; bahma=s; n=s.size(); //cout <<n<<endl; for (int i = 1; i < n; ++i) { if(s[i]=='_') pre[i]=1; else if(s[i]=='X') suf[i]=1; pre[i]+=pre[i-1]; suf[i]+=suf[i-1]; } dfs(0,0); for (int i = 1; i <= n; ++i) { for (int j = 0; j < m; ++j) { if(ok[i][j]){ //cout <<i<<" "<<j<<endl; for (int k = i; k <= i+c[j]-1; ++k) { ok[k][n+1]=true; } } } } for (int i = 1; i <= n; ++i) { for (int j = 1; j <= n; ++j) { if(bad[i][j]){ for (int k = i; k <= i+j; ++k) { bad[k][0]=true; } } } } string res=""; for (int i = 1; i <= n; ++i) { //cout <<res<<endl; //cout <<ok[i][0]<<" "; if(s[i]!='.') res.push_back(s[i]); else if(ok[i][n+1]&&bad[i][0]) res.push_back('?'); else if(ok[i][n+1]) res.push_back('X'); else res.push_back('_'); } return res; } /*int main() { #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif assert(1 == scanf("%s", buf)); std::string s = buf; int c_len; assert(1 == scanf("%d", &c_len)); std::vector<int> c(c_len); for (int i = 0; i < c_len; i++) { assert(1 == scanf("%d", &c[i])); } std::string ans = solve_puzzle(s, c); printf("%s\n", ans.data()); return 0; }*/

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

/usr/bin/ld: /tmp/ccQ3nofY.o:(.bss+0x0): multiple definition of `buf'; /tmp/ccjnjmSV.o:(.bss+0x196e720): first defined here
collect2: error: ld returned 1 exit status