QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#626183 | #4832. Telepathy | Hamed5001 | 0 | 12ms | 14444kb | C++14 | 1.6kb | 2024-10-10 00:05:38 | 2024-10-10 00:05:38 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
template<typename T> void umin(T &a, T b) {a = min(a, b);}
long double randomFloat() {
return (long double)rand() / RAND_MAX;
}
int main() {
cin.tie(0)->sync_with_stdio(false);
srand(98);
string S; cin >> S;
int N, K; cin >> N >> K;
string A; cin >> A;
if (S == "Flim") {
for (int i = 1; i <= K; ++i) cout << i << ' ';
}
else {
vector<long double> prop;
vector<array<int, 2>> nxt(N + 1, {(int)1e9, (int)1e9});
for (int i = 0; i < N; ++i) {
if (A[i] - '0') nxt[i][1] = i;
else nxt[i][0] = i;
}
for (int i = N - 1; ~i; --i) {
umin(nxt[i][1], nxt[i + 1][1]);
umin(nxt[i][0], nxt[i + 1][0]);
}
int last = A[0] - '0';
cout << 1;
int j = 1;
long long same = 2;
for (int i = 1; i < K; ++i) {
cout << ' ';
if (nxt[j][1] == 1e9 || N - nxt[j][1] < K - i - 1) {
cout << nxt[j][0] + 1;
j = nxt[j][0] + 1;
continue;
}
if (nxt[j][0] == 1e9 || N - nxt[j][0] < K - i - 1) {
cout << nxt[j][1] + 1;
j = nxt[j][1] + 1;
continue;
}
long double s_p = randomFloat();
prop.push_back(s_p);
if (s_p <= 1 / same) {
cout << nxt[j][last] + 1;
j = nxt[j][last] + 1;
same <<= 1;
}
else {
last = 1 - last;
cout << nxt[j][last] + 1;
same = 2;
j = nxt[j][last] + 1;
}
}
//cerr << endl;
//for (auto it : prop) cerr << it << ' ';
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 12ms
memory: 14444kb
input:
Flim 1000000 100000 1101111111100010011110111001110011110110100000111110011111111111110111110100000001001000000110111000000101110000001100111110100100000100010111001011111010001000101100101100001111011100110010010000100100100101110100100110101001001000001011111101111111001100101000010110001011011000...
output:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 ...
input:
Flam 1000000 100000 0000001101000100010010001001011111000101010011011001010100101001110101001011001011100001011100110100011110011010100101110101101101100101111011000111001101001100010000010010101110101010111110001100110000110001001111010010000010111101110001011011101101010000111111011111100100010001...
output:
1 7 9 10 11 14 15 18 19 21 22 25 26 28 29 30 35 38 39 40 41 42 43 45 47 48 50 52 53 54 55 56 57 59 60 61 62 64 67 68 69 70 71 73 74 75 77 79 80 81 84 88 89 90 93 95 97 98 99 102 106 108 110 111 112 113 114 116 117 118 121 122 123 124 126 127 129 130 132 134 135 136 140 141 143 146 149 151 153 154 15...
result:
wrong answer 50342 matched, but you need to match at least 66666 positions