제출 #1044578

#제출 시각아이디문제언어결과실행 시간메모리
1044578fv3Paint By Numbers (IOI16_paint)C++14
32 / 100
1 ms348 KiB
#include "paint.h" #include <bits/stdc++.h> using namespace std; int N, M; string solve_puzzle(string s, vector<int> c) { N = s.size(); M = c.size(); vector<int> preSum(M); vector<int> sufSum(M, N); int l = 0; for (int i = 0; i < M; i++) { for (int j = l; j < l + c[i]; j++) { if (s[j] == '_') l = j + 1; } preSum[i] = l; l += c[i] + 1; } int r = N - 1; for (int i = M - 1; i >= 0; i--) { for (int j = r; j > r - c[i]; j--) { if (s[j] == '_') r = j - 1; } sufSum[i] = r - c[i] + 1; r -= c[i] + 1; } string res = s; for (int i = 0; i < M; i++) { for (int j = sufSum[i]; j < preSum[i] + c[i]; j++) res[j] = 'X'; } int cnt = 0; for (auto c : res) c=='X'&&cnt++; int sum = 0; for (auto n : c) sum += n; if (cnt == sum) { for (auto&c : res) { if (c == '.') c = '_'; } } else { for (auto&c : res) { if (c == '.') c = '?'; } } return res; }
#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...