이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <random>
#include <chrono>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <queue>
using namespace std;
void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail>
void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#define rng_init mt19937 rng(chrono::steady_clock::now().time_since_epock().count())
#define rng_seed(x) mt19937 rng(x)
#define all(x) (x).begin(), (x).end()
#define sz(x) (int) (x).size()
// #define int long long
const int MXN = 1e5 + 1, INF = 1e9 + 5;
string solve_puzzle(string s, vector<int> c) {
int N = sz(s), K = sz(c);
deque<char> dq;
for (int i = 0; i < K; i++) {
for (int j = 0; j < c[i]; j++)
dq.push_back('X');
if (i < K - 1)
dq.push_back('_');
}
while (sz(dq) < N)
dq.push_back('_');
// for (const auto &x : dq)
// cout << x;
vector<int> cnt(N, 0);
for (int iter = 0; iter < N; iter++) {
for (int i = 0; i < sz(dq); i++) {
if (dq[i] == 'X') cnt[i]++;
}
if (dq.back() != 'X') {
dq.push_front('_');
dq.pop_back();
}
}
string ans;
for (int i = 0; i < N; i++) {
if (cnt[i] >= N) ans += 'X';
else if (cnt[i] > 0) ans += '?';
else ans += '_';
}
return ans;
}
// void solve() {
// cout << solve_puzzle(".........", vector<int>{1, 1, 1, 1, 1});
// }
// signed main() {
// ios_base::sync_with_stdio(false);
// cin.tie(nullptr);
// int TC = 1;
// // cin >> TC;
// while (TC--) solve();
// }
# | 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... |