QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#740023 | #9614. 分治 | hos_lyric | 40 | 26ms | 4096kb | C++14 | 2.1kb | 2024-11-13 00:25:13 | 2024-11-13 00:25:14 |
Judging History
answer
#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using Int = long long;
template <class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &a) { return os << "(" << a.first << ", " << a.second << ")"; };
template <class T> ostream &operator<<(ostream &os, const vector<T> &as) { const int sz = as.size(); os << "["; for (int i = 0; i < sz; ++i) { if (i >= 256) { os << ", ..."; break; } if (i > 0) { os << ", "; } os << as[i]; } return os << "]"; }
template <class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cerr << *i << " "; cerr << endl; }
template <class T> bool chmin(T &t, const T &f) { if (t > f) { t = f; return true; } return false; }
template <class T> bool chmax(T &t, const T &f) { if (t < f) { t = f; return true; } return false; }
#define COLOR(s) ("\x1b[" s "m")
int N;
int scores[2];
void dfs(int l, int r, const string &path) {
if (l + 1 == r) {
int mxs[2] = {1, 1};
for (int i = 0, j = 0; i < (int)path.size(); ++i) {
for (; j < (int)path.size() && path[i] == path[j]; ++j) {}
chmax(mxs[path[i] - '0'], j - i + 1);
}
scores[0] += mxs[0];
scores[1] += mxs[1];
} else {
const int m = (l + r) / 2;
dfs(l, m, path + '0');
dfs(m, r, path + '1');
}
}
int main() {
#ifdef LOCAL
for (N = 1; N <= 128; ++N) {
scores[0] = scores[1] = 0;
dfs(0, N, "");
cerr << N << ": " << scores[0] << " " << scores[1] << endl;
assert(scores[0] <= scores[1]);
}
#endif
char S[20];
for (; ~scanf("%s", S); ) {
N = 0;
for (char *s = S; *s; ++s) (N <<= 1) |= (*s - '0');
scores[0] = scores[1] = 0;
dfs(0, N, "");
printf("%d\n", scores[1]);
}
return 0;
}
詳細信息
Subtask #1:
score: 10
Accepted
Test #1:
score: 10
Accepted
time: 0ms
memory: 3760kb
input:
110
output:
15
result:
ok 1 number(s): "15"
Test #2:
score: 10
Accepted
time: 0ms
memory: 4096kb
input:
101
output:
12
result:
ok 1 number(s): "12"
Subtask #2:
score: 10
Accepted
Dependency #1:
100%
Accepted
Test #3:
score: 10
Accepted
time: 0ms
memory: 3800kb
input:
111110
output:
198
result:
ok 1 number(s): "198"
Test #4:
score: 10
Accepted
time: 0ms
memory: 3792kb
input:
1001001
output:
253
result:
ok 1 number(s): "253"
Subtask #3:
score: 20
Accepted
Dependency #2:
100%
Accepted
Test #5:
score: 20
Accepted
time: 9ms
memory: 4036kb
input:
10100011000100111
output:
386882
result:
ok 1 number(s): "386882"
Test #6:
score: 20
Accepted
time: 26ms
memory: 3856kb
input:
111010011111010110
output:
1107742
result:
ok 1 number(s): "1107742"
Subtask #4:
score: 0
Memory Limit Exceeded
Test #7:
score: 0
Memory Limit Exceeded
input:
100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
output:
result:
Subtask #5:
score: 0
Skipped
Dependency #3:
100%
Accepted
Dependency #4:
0%
Subtask #6:
score: 0
Skipped
Dependency #4:
0%
Subtask #7:
score: 0
Skipped
Dependency #5:
0%
Subtask #8:
score: 0
Skipped
Dependency #6:
0%
Subtask #9:
score: 0
Skipped
Dependency #1:
100%
Accepted
Dependency #2:
100%
Accepted
Dependency #3:
100%
Accepted
Dependency #4:
0%