QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#117657 | #6628. Flip it and Stick it | xcyle | Compile Error | / | / | C++14 | 2.9kb | 2023-07-01 21:45:09 | 2023-07-01 21:45:12 |
Judging History
你现在查看的是最新测评结果
- [2023-08-10 23:21:45]
- System Update: QOJ starts to keep a history of the judgings of all the submissions.
- [2023-07-01 21:45:12]
- 评测
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2023-07-01 21:45:09]
- 提交
answer
/*
_/ _/ _/_/_/ _/ _/ _/ _/_/_/_/_/
_/ _/ _/ _/ _/ _/ _/ _/
_/ _/ _/ _/ _/ _/ _/
_/_/ _/ _/ _/ _/_/_/_/
_/ _/ _/ _/ _/ _/
_/ _/ _/ _/ _/ _/ _/
_/ _/ _/_/_/ _/ _/_/_/_/_/ _/_/_/_/_/
*/
#include <bits/stdc++.h>
#define ll long long
#define lc(x) ((x) << 1)
#define rc(x) ((x) << 1 | 1)
#define ru(i, l, r) for (int i = (l); i <= (r); i++)
#define rd(i, r, l) for (int i = (r); i >= (l); i--)
#define mid ((l + r) >> 1)
#define pii pair<int, int>
#define mp make_pair
#define fi first
#define se second
#define sz(s) (int)s.size()
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
using namespace std;
mt19937 Rand(chrono::steady_clock::now().time_since_epoch().count());
int read() {
int x = 0, w = 0; char ch = getchar();
while(!isdigit(ch)) w |= ch == '-', ch = getchar();
while(isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
return w ? -x : x;
}
char s[200005], t[10];
int main() {
scanf("%s%s", s + 1, t + 1);
int n = strlen(s + 1), m = strlen(t + 1);
if(t[1] == '1') {
ru(i, 1, n) s[i] = '0' + '1' - s[i];
ru(i, 1, m) t[i] = '0' + '1' - t[i];
}
if(m == 1) {
int fl = 1;
ru(i, 1, n) fl &= s[i] != '0';
printf("%d\n", fl - 1);
}
if(m == 2) {
if(t[2] == '0') {
int sum = 0;
ru(i, 1, n) sum += (s[i] == '0') - (s[i] == '1');
if(sum <= 1) {
int cnt = 0;
ru(i, 1, n - 1) cnt += s[i] == '0' && s[i + 1] == '0';
printf("%d\n", cnt);
}
else printf("-1\n");
}
else {
int cnt = 0;
ru(i, 1, n - 1) cnt += s[i] == '0' && s[i + 1] == '1';
printf("%d\n", cnt);
}
}
if(m == 3) {
if(t[2] == '0' && t[3] == '0') {
int sum = 0;
ru(i, 1, n) sum += (s[i] == '0') - 2 * (s[i] == '1');
if(sum <= 2) {
int las = 1, cnt = 0;
s[n + 1] = '1';
ru(i, 1, n + 1) if(s[i] == '1') {
if(las < i) cnt += (i - las - 1) / 2;
las = i + 1;
}
printf("%d\n", cnt);
}
else printf("-1\n");
}
if(t[2] == '1' && t[3] == '1') {
reverse(s + 1, s + n + 1);
ru(i, 1, n) s[i] = '0' + '1' - s[i];
t[2] = '0';
}
if(t[2] == '0' && t[3] == '1') {
int cnt = 0;
ru(i, 1, n - 2) if(s[i] == '0' && s[i + 1] == '0' && s[i + 2] == '1') cnt++;
printf("%d\n", cnt);
}
if(t[2] == '1' && t[3] == '0') {
ru(i, 1, n - 2) if(s[i] == '0' && s[i + 1] == '1' && s[i + 2] == '0') cnt++;
printf("%d\n", (cnt + 1) / 2);
}
}
return 0;
}
详细
answer.code: In function ‘int main()’: answer.code:92:87: error: ‘cnt’ was not declared in this scope; did you mean ‘int’? 92 | ru(i, 1, n - 2) if(s[i] == '0' && s[i + 1] == '1' && s[i + 2] == '0') cnt++; | ^~~ | int answer.code:93:33: error: ‘cnt’ was not declared in this scope; did you mean ‘int’? 93 | printf("%d\n", (cnt + 1) / 2); | ^~~ | int answer.code:38:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 38 | scanf("%s%s", s + 1, t + 1); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~