提出 #26963566
ソースコード 拡げる
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <chrono>
#include <random>
constexpr int maxn = 200005;
char s[3*maxn];
char taken[3*maxn];
int n;
bool try_take(const char *p, int rep, int set) {
if (rep == 0) return true;
int j = 0;
for (int i = 0, r = 0; i < 3*n && j < 3; ++i) {
if (!taken[i] && s[i] == p[j]) {
if (set) taken[i] = set;
if (++r == rep) ++j, r = 0;
}
}
return j == 3;
}
int it = '0';
void take(const char *p) {
int l = 0, h = 3*n+1;
while (l < h) {
int m = l + (h-l+1)/2;
if (try_take(p, m, 0)) l = m;
else h = m-1;
}
try_take(p, l, ++it);
}
constexpr char perms[6][4] = {
"ABC",
"ACB",
"BAC",
"BCA",
"CAB",
"CBA"
};
int ord[6] = {0,1,2,3,4,5};
int64_t now() {
return std::chrono::high_resolution_clock::now().time_since_epoch().count();
}
int main() {
scanf("%d%600005s", &n, s);
int64_t st = now();
std::default_random_engine rng (st);
while (now() - st < 1.6e9) {
std::shuffle(ord, ord+6, rng);
memset(taken, 0, 3*n*sizeof(taken[0])), it = '0';
for (int i = 0; i < 6; ++i) take(perms[ord[i]]);
if (strlen(taken) == 3*n) break;
}
puts(taken);
#ifdef LOCAL
fprintf(stderr, "Time elapsed: %.3f ms\n", (now() - st) / 1e6);
#endif // LOCAL
}
提出情報
| 提出日時 | |
|---|---|
| 問題 | A - ABC Identity |
| ユーザ | ritwin |
| 言語 | C++ (GCC 9.2.1) |
| 得点 | 0 |
| コード長 | 1304 Byte |
| 結果 | WA |
| 実行時間 | 1623 ms |
| メモリ | 4336 KiB |
コンパイルエラー
./Main.cpp: In function ‘int main()’:
./Main.cpp:61:21: warning: comparison of integer expressions of different signedness: ‘size_t’ {aka ‘long unsigned int’} and ‘int’ [-Wsign-compare]
61 | if (strlen(taken) == 3*n) break;
| ~~~~~~~~~~~~~~^~~~~~
./Main.cpp:52:7: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
52 | scanf("%d%600005s", &n, s);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~
ジャッジ結果
| セット名 | Sample | All | ||||||
|---|---|---|---|---|---|---|---|---|
| 得点 / 配点 | 0 / 0 | 0 / 400 | ||||||
| 結果 |
|
|
| セット名 | テストケース |
|---|---|
| Sample | 01.txt, 02.txt |
| All | 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 30.txt, 31.txt, 32.txt, 33.txt, 34.txt, 35.txt, 36.txt, 37.txt, 38.txt, 39.txt, 40.txt, 41.txt, 42.txt, 43.txt, 44.txt, 45.txt, 46.txt |
| ケース名 | 結果 | 実行時間 | メモリ |
|---|---|---|---|
| 01.txt | AC | 8 ms | 3056 KiB |
| 02.txt | AC | 2 ms | 3168 KiB |
| 03.txt | AC | 2 ms | 2984 KiB |
| 04.txt | AC | 2 ms | 3168 KiB |
| 05.txt | AC | 3 ms | 3120 KiB |
| 06.txt | AC | 4 ms | 3128 KiB |
| 07.txt | AC | 2 ms | 3156 KiB |
| 08.txt | AC | 2 ms | 3080 KiB |
| 09.txt | AC | 2 ms | 3040 KiB |
| 10.txt | AC | 2 ms | 3048 KiB |
| 11.txt | AC | 2 ms | 3056 KiB |
| 12.txt | AC | 3 ms | 3052 KiB |
| 13.txt | AC | 2 ms | 3076 KiB |
| 14.txt | AC | 2 ms | 3156 KiB |
| 15.txt | AC | 3 ms | 2988 KiB |
| 16.txt | AC | 2 ms | 3168 KiB |
| 17.txt | AC | 1 ms | 3060 KiB |
| 18.txt | AC | 5 ms | 3056 KiB |
| 19.txt | AC | 5 ms | 3088 KiB |
| 20.txt | AC | 6 ms | 3060 KiB |
| 21.txt | AC | 5 ms | 3072 KiB |
| 22.txt | AC | 4 ms | 3056 KiB |
| 23.txt | AC | 5 ms | 3028 KiB |
| 24.txt | AC | 5 ms | 2996 KiB |
| 25.txt | AC | 3 ms | 2992 KiB |
| 26.txt | AC | 253 ms | 4212 KiB |
| 27.txt | AC | 270 ms | 4292 KiB |
| 28.txt | AC | 235 ms | 4216 KiB |
| 29.txt | AC | 781 ms | 4332 KiB |
| 30.txt | AC | 469 ms | 4148 KiB |
| 31.txt | AC | 1000 ms | 4324 KiB |
| 32.txt | AC | 753 ms | 4148 KiB |
| 33.txt | AC | 511 ms | 4328 KiB |
| 34.txt | AC | 259 ms | 4180 KiB |
| 35.txt | AC | 949 ms | 4324 KiB |
| 36.txt | AC | 449 ms | 4156 KiB |
| 37.txt | AC | 1469 ms | 4324 KiB |
| 38.txt | AC | 509 ms | 4236 KiB |
| 39.txt | AC | 1120 ms | 4224 KiB |
| 40.txt | AC | 236 ms | 4244 KiB |
| 41.txt | AC | 469 ms | 4216 KiB |
| 42.txt | AC | 533 ms | 4324 KiB |
| 43.txt | AC | 506 ms | 4224 KiB |
| 44.txt | AC | 508 ms | 4236 KiB |
| 45.txt | WA | 1623 ms | 4224 KiB |
| 46.txt | AC | 559 ms | 4336 KiB |