Submission #19559659
Source Code Expand
Copy
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPr(i, n) for(int i = (n)-1; i >= 0; --i)
#define FORq(i, m, n) for(int i = (m); i <= (n); ++i)
#define FORqr(i, m, n) for(int i = (n); i >= (m); --i)
#define MP make_pair
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x, 0, sizeof(x))
#define FILL(x, y) memset(x, y, sizeof(x))
#define MM(x) memset(x, -1, sizeof(x))
#define ALL(x) (x).begin(), (x).end()
#define DB(x) cerr << #x << " = " << x << endl
#define DB2(x, y) \
cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n";
#define DB3(x, y, z) \
cerr << "(" << #x << ", " << #y << ", " << #z << ") = (" << x << ", " << y << ", " << z << ")\n";
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
const long long MOD = 1e9 + 7;
///////////////////////////////////////////////
// for template
template <class T> inline bool chmin(T &a, T b) {
if(a > b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmax(T &a, T b) {
if(a < b) {
a = b;
return true;
}
return false;
}
///////////////////////////////////////////////
/// 🍈( '-' 🍈 |AC|
ll N;
string T;
ll solve(ll N, string T){
ll Z = 0;
for (auto t: T){
if (t == '0') Z++;
}
REP(i,N - 2){
if ((T[i] == '1') and (T[i + 1] == '1') and (T[i + 2] == '1')){
return 0;
}
}
if (Z == 0){
if (N == 1) return 2 * 1e10;
if (N == 2) return 1e10;
}else if (Z == 1){
ll x = 0;
ll y = 0;
bool z = false;
for (auto t : T){
if (t == '0') z = true;
if (t == '1'){
if (z) y++;
else x++;
}
}
if (y == 0) return 1e10;
else return 1e10 - 1;
}else{
ll x = 0;
ll y = 0;
int m = 0;
REP(i, N){
char c = T[i];
if (c == '1') x++;
else break;
}
REPr(i, N){
char c = T[i];
if (c == '1') y++;
else break;
}
//DB2(x,y);
FORq(i,x,N - 1 - y){
int j = i - x;
if (j % 3 == 0){
if (T[i] != '0') return 0;
}else{
if (T[i] != '1') return 0;
}
}
return 1e10 - Z + 1 - (y != 0);
}
}
int main() {
cin >> N;
cin >> T;
cout << solve(N, T) << endl;
}
Submission Info
Submission Time
2021-01-22 12:44:35+0900
Task
B - Many 110
User
Lithium
Language
C++ (GCC 9.2.1)
Score
400
Code Size
2996 Byte
Status
AC
Exec Time
15 ms
Memory
3824 KB
Compile Error
./Main.cpp: In function ‘ll solve(ll, std::string)’:
./Main.cpp:83:13: warning: unused variable ‘m’ [-Wunused-variable]
83 | int m = 0;
| ^
./Main.cpp:109:1: warning: control reaches end of non-void function [-Wreturn-type]
109 | }
| ^
Judge Result
Set Name
All
Sample
Score / Max Score
400 / 400
0 / 0
Status
Set Name
Test Cases
All
sample_01.txt, sample_02.txt, testcase_1.txt, testcase_10.txt, testcase_11.txt, testcase_12.txt, testcase_13.txt, testcase_14.txt, testcase_15.txt, testcase_16.txt, testcase_17.txt, testcase_18.txt, testcase_19.txt, testcase_2.txt, testcase_20.txt, testcase_21.txt, testcase_22.txt, testcase_23.txt, testcase_24.txt, testcase_25.txt, testcase_26.txt, testcase_27.txt, testcase_28.txt, testcase_29.txt, testcase_3.txt, testcase_30.txt, testcase_4.txt, testcase_5.txt, testcase_6.txt, testcase_7.txt, testcase_8.txt, testcase_9.txt
Sample
sample_01.txt, sample_02.txt
Case Name
Status
Exec Time
Memory
sample_01.txt
AC
7 ms
3448 KB
sample_02.txt
AC
2 ms
3444 KB
testcase_1.txt
AC
2 ms
3388 KB
testcase_10.txt
AC
2 ms
3468 KB
testcase_11.txt
AC
2 ms
3428 KB
testcase_12.txt
AC
2 ms
3428 KB
testcase_13.txt
AC
2 ms
3576 KB
testcase_14.txt
AC
2 ms
3560 KB
testcase_15.txt
AC
12 ms
3760 KB
testcase_16.txt
AC
11 ms
3760 KB
testcase_17.txt
AC
15 ms
3824 KB
testcase_18.txt
AC
5 ms
3700 KB
testcase_19.txt
AC
3 ms
3664 KB
testcase_2.txt
AC
2 ms
3388 KB
testcase_20.txt
AC
3 ms
3600 KB
testcase_21.txt
AC
6 ms
3560 KB
testcase_22.txt
AC
3 ms
3648 KB
testcase_23.txt
AC
2 ms
3448 KB
testcase_24.txt
AC
7 ms
3644 KB
testcase_25.txt
AC
9 ms
3688 KB
testcase_26.txt
AC
9 ms
3516 KB
testcase_27.txt
AC
6 ms
3648 KB
testcase_28.txt
AC
4 ms
3700 KB
testcase_29.txt
AC
2 ms
3440 KB
testcase_3.txt
AC
2 ms
3424 KB
testcase_30.txt
AC
2 ms
3580 KB
testcase_4.txt
AC
2 ms
3468 KB
testcase_5.txt
AC
2 ms
3568 KB
testcase_6.txt
AC
1 ms
3568 KB
testcase_7.txt
AC
2 ms
3424 KB
testcase_8.txt
AC
2 ms
3448 KB
testcase_9.txt
AC
2 ms
3564 KB