제출 #430026

#제출 시각아이디문제언어결과실행 시간메모리
430026LouayFarahPaint By Numbers (IOI16_paint)C++14
32 / 100
1 ms304 KiB
#include "bits/stdc++.h" #include "paint.h" using namespace std; #define pb push_back string solve_puzzle(string s, vector<int> c) { int n = (int)s.length(); int k = (int)c.size(); string res = s; int i = 0, clue = 0; while(i<n&&clue<k) { int temp = c[clue]; while(i<n&&temp>0) { res[i] = 'X'; i++; temp--; } if(i<n) res[i] = '_'; i++; clue++; } while(i<n) res[i++] = '_'; vector<int> pos; i = 0; while(i<n) { if(res[i]=='X') { pos.pb(i); while(i<n&&res[i]=='X') i++; } i++; } vector<int> visited(n, 0); for(int j = 0; j<n; j++) { if(res[j]=='X') visited[j] = 2; else visited[j] = 1; } for(int p = k-1; p>=0; p--) { int position = pos[p]; int len = c[p]; while(position+len<n) { if(position+len-1<n-2) { if(res[position+len]=='_'&&res[position+len+1]=='X') break; } res[position] = '_'; res[position+len] = 'X'; position++; for(int j = 0; j<n; j++) { if(visited[j]==1&&res[j]=='X') visited[j]=3; else if(visited[j]==2&&res[j]=='_') visited[j]=3; } } } string fin = ""; for(int j = 0; j<n; j++) { if(visited[j]==1) fin.pb('_'); else if(visited[j]==2) fin.pb('X'); else fin.pb('?'); } return fin; }
#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...