QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#163610 | #5981. Costly Binary Search | NGC5457 | 0 | 6786ms | 91464kb | C++14 | 2.1kb | 2023-09-04 12:30:31 | 2023-09-04 12:30:32 |
Judging History
answer
/* 陽炎は黄泉に待たむと。*/
#include <bits/stdc++.h>
using namespace std;
#define inl inline
constexpr int BUF = 1<<19;
char ibuf[BUF], *__st, *__ed;
inl void buffer () { __st = ibuf,
__ed = ibuf + fread (ibuf, 1, BUF, stdin); }
inl char getc () {
return __st == __ed && (buffer (),
__st == __ed) ? EOF : *__st++; }
inl int read (char *s) {
static char c = getc ();
for (; ~c && isspace (c); c = getc ());
if (c == EOF) return 0; int len = 0;
for (; ~c && !isspace (c); c = getc ())
*s++ = c, ++len; return *s = 0, len;
}
typedef long long ll;
typedef unsigned long long ull;
// typedef __int128 lll;
// typedef long double llf;
typedef pair <int, int> pint;
#define fst first
#define scd second
#define all(p) begin (p), end (p)
#define empb emplace_back
#ifdef SHIKEN
#define msg(args...) fprintf (stderr, args)
#else
#define msg(...) void ()
#endif
constexpr int N = 1e6 + 10, INF = 0x3f3f3f3f;
int _lbd[10][N], _rbd[10][N], T, n, f[N], g[N]; char a[N];
inl void gomn (int &x, int y) { if (x > y) x = y; }
inl void gomx (int &x, int y) { if (x < y) x = y; }
int main () {
/* */
int *lbd[200], *rbd[200];
for (int i = 0; i < 200; ++i)
lbd[i] = _lbd[i % 10],
rbd[i] = _rbd[i % 10];
scanf ("%d", &T);
for (int t = 1; t <= T; ++t) {
n = read (a + 1); int c = 0, ans = INF;
memset (_lbd, 0x3f, sizeof _lbd);
memset (_rbd, ~0x3f, sizeof _rbd);
for (int i = 1; i <= n; ++i)
a[i] -= '0', f[i] = g[i] = i;
while (c < ans) {
for (int i = 1, r = rbd[c][0]; i <= n; ++i) {
if (rbd[c][i] > r) r = rbd[c][i];
if (g[i] < r) g[i] = r;
}
int s = 0;
for (int i = n, l = lbd[c][n + 1]; i; --i) {
if (lbd[c][i] < l) l = lbd[c][i];
if (l < f[i]) f[i] = l;
s |= (f[i] == 1 && g[i] == n)<<a[i];
}
ans = min (ans, __builtin_ctz (s) + c);
for (int i = 1; i <= n; ++i) {
gomn (lbd[c + a[i]][g[i] + 1], f[i]);
gomx (rbd[c + a[i]][f[i] - 1], g[i]);
}
memset (lbd[c], 0x3f, sizeof _lbd[0]);
memset (rbd[c], ~0x3f, sizeof _rbd[0]);
++c;
}
printf ("Case #%d: %d\n", t, ans);
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 1076ms
memory: 83540kb
input:
50 8 5128831164925953487661279378526736416489768154389124821528467927357884749642747626797857463132866343496157991453139582295398452863172464853698678624523849653538713928372648295734165346972222781179687541337591976277864785653638476127839556323849395641196246971351933655287441377531627938395427487...
output:
Case #1: 8 Case #2: 32 Case #3: 32 Case #4: 32 Case #5: 32 Case #6: 32 Case #7: 32 Case #8: 24 Case #9: 32 Case #10: 32 Case #11: 32 Case #12: 32 Case #13: 32 Case #14: 32 Case #15: 32 Case #16: 32 Case #17: 14 Case #18: 32 Case #19: 32 Case #20: 32 Case #21: 32 Case #22: 32 Case #23: 14 Case #24: 9...
result:
wrong answer 2nd lines differ - expected: 'Case #2: 37', found: 'Case #2: 32'
Subtask #2:
score: 0
Wrong Answer
Test #2:
score: 0
Wrong Answer
time: 6786ms
memory: 91464kb
input:
50 647322722753778843259213887674615134214258235986992692879314555957455541351526284343217116351733247781713552149464672262787737941588358671583528664757823365936975517145283412965139791726299864122725212222496898855627124979178341548651669956711341742838725446489235961853391195148929571712449139335...
output:
Case #1: 32 Case #2: 32 Case #3: 32 Case #4: 32 Case #5: 32 Case #6: 32 Case #7: 31 Case #8: 32 Case #9: 32 Case #10: 32 Case #11: 32 Case #12: 32 Case #13: 32 Case #14: 32 Case #15: 32 Case #16: 20 Case #17: 32 Case #18: 30 Case #19: 32 Case #20: 32 Case #21: 32 Case #22: 31 Case #23: 32 Case #24: ...
result:
wrong answer 1st lines differ - expected: 'Case #1: 42', found: 'Case #1: 32'