이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "paint.h"
#include <cstdlib>
#include <bits/stdc++.h>
using namespace std;
vector<int> occur1, occur2;
vector<int> arr;
int n;
int k;
int how = 0;
vector<int> p(21);
void calc(int x){
string res = "";
for(int i = 0; i<n; i++){
if(x&p[i]) res+='X';
else res+='_';
}
int cnt = 0;
int j = 0;
for(int i = 0; i<n; i++){
if(res[i] == '_' and cnt){
if(j==k) return;
else {
if(cnt != arr[j]) return;
else {
j++; cnt = 0;
}
}
}
else if(res[i] == 'X'){
cnt++;
}
}
if(cnt and j==k) return;
if(cnt and cnt != arr[j]) return;
if(cnt and cnt == arr[j] and j+1<k) return;
if(!cnt and j<k) return;
how++;
for(int i = 0; i<n; i++){
if(res[i] == 'X') occur1[i]++;
else occur2[i]++;
}
}
std::string solve_puzzle(std::string s, std::vector<int> c) {
n = s.size();
k = c.size();
occur1.assign(n,0);
occur2.assign(n,0);
arr = c;
p[0] = 1;
for(int i = 1; i<21; i++) p[i]=p[i-1]<<1;
for(int i = 0; i<(1<<n); i++){
calc(i);
}
string ans = "";
for(int i = 0; i<n; i++){
if(occur1[i] == how) ans+="X";
else if(occur2[i] == how) ans+="_";
else ans+="?";
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |