QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#203273 | #7109. Traveling on the Axis | siro53 | AC ✓ | 4ms | 3576kb | C++17 | 2.6kb | 2023-10-06 16:32:57 | 2023-10-06 16:32:58 |
Judging History
answer
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
if(a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> inline bool chmin(T &a, T b) {
if(a > b) {
a = b;
return 1;
}
return 0;
}
#ifdef DEBUG
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
os << '(' << p.first << ',' << p.second << ')';
return os;
}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
os << '{';
for(int i = 0; i < (int)v.size(); i++) {
if(i) { os << ','; }
os << v[i];
}
os << '}';
return os;
}
void debugg() { cerr << endl; }
template <class T, class... Args>
void debugg(const T &x, const Args &... args) {
cerr << " " << x;
debugg(args...);
}
#define debug(...) \
cerr << __LINE__ << " [" << #__VA_ARGS__ << "]: ", debugg(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif
struct Setup {
Setup() {
cin.tie(0);
ios::sync_with_stdio(false);
cout << fixed << setprecision(15);
}
} __Setup;
using ll = long long;
#define OVERLOAD3(_1, _2, _3, name, ...) name
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define REP1(i, n) for(int i = 0; i < int(n); i++)
#define REP2(i, a, b) for(int i = (a); i < int(b); i++)
#define REP(...) OVERLOAD3(__VA_ARGS__, REP2, REP1)(__VA_ARGS__)
#define UNIQUE(v) sort(ALL(v)), (v).erase(unique(ALL(v)), (v).end())
#define REVERSE(v) reverse(ALL(v))
#define SZ(v) ((int)(v).size())
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
constexpr int MOD = 1000000007;
constexpr int MOD2 = 998244353;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
void Case(int i) { cout << "Case #" << i << ": "; }
int popcount(int x) { return __builtin_popcount(x); }
ll popcount(ll x) { return __builtin_popcountll(x); }
#pragma endregion Macros
void solve() {
string s;
cin >> s;
int N = SZ(s);
int zero = 0, one = 0;
ll sum = 0, ans = 0;
REP(i, N) {
zero++;
if(s[i] == '0') {
sum += zero * 2 + one;
zero += one;
one = 0;
} else {
sum += zero + one * 2;
one += zero;
zero = 0;
}
ans += sum;
}
cout << ans << '\n';
}
int main() {
int T{1};
cin >> T;
while(T--) solve();
}
这程序好像有点Bug,我给组数据试试?
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3404kb
input:
3 101 011 11010
output:
12 15 43
result:
ok 3 lines
Test #2:
score: 0
Accepted
time: 4ms
memory: 3576kb
input:
6107 1010101 010110100110101 1010 1010101010010101010 101011 0101101011010101010 0101101011 11011010101 010 1011010 10110101010101010100 010101010110101 10101010101011 0101010101010101011 00101010011000 1010101010010110110 01010101001010101010 101010101010101 100100101010101010 01 011 0101010100101 ...
output:
96 889 24 1515 69 1567 279 345 14 106 1702 791 621 1447 764 1615 1755 736 1333 6 15 542 44 1689 1515 140 833 497 596 24 1640 694 462 30 425 14 1041 1446 96 504 124 75 560 970 771 945 6 1 321 137 786 720 206 769 46 103 225 74 554 2 100 529 260 207 197 2 197 1041 140 857 207 1 74 1604 41 343 1041 14 1...
result:
ok 6107 lines
Extra Test:
score: 0
Extra Test Passed