Submission #1025913


Source Code Expand

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int const MOD = 1000000007;

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

signed main() {
    string s; cin >> s;
    s += "0";
    int ans = 0;
    int cnt = 1;
    int prev = -1;
    rep(i,0,s.length()) {
        if(prev == -1) {
            if(s[i] - '0' == 2) {
                prev = s[i] - '0';
            }
        }
        else {
            if(prev == 2 && s[i] - '0' == 5) {
                cnt++;
                prev = 5;
            }
            else if(prev == 5 && s[i] - '0' == 2) {
                cnt++;
                prev = 2;
            }
            else {
                if(s[i] - '0' == 2) prev = 2;
                else prev = -1;

                int c = cnt / 2;
                ans += c * (c+1) / 2;
                cnt = 1;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Submission Info

Submission Time
Task B - ニコニコ文字列
User tsutaj
Language C++ (G++ 4.6.4)
Score 100
Code Size 2203 Byte
Status AC
Exec Time 22 ms
Memory 1056 KB

Judge Result

Set Name Sample Subtask1 All
Score / Max Score 0 / 0 30 / 30 70 / 70
Status
AC × 5
AC × 18
AC × 30
Set Name Test Cases
Sample subtask0_sample_01.txt, subtask0_sample_02.txt, subtask0_sample_03.txt, subtask0_sample_04.txt, subtask0_sample_05.txt
Subtask1 subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt, subtask0_sample_01.txt, subtask0_sample_02.txt, subtask0_sample_03.txt, subtask0_sample_04.txt, subtask0_sample_05.txt
All subtask0_sample_01.txt, subtask0_sample_02.txt, subtask0_sample_03.txt, subtask0_sample_04.txt, subtask0_sample_05.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt, subtask2_01.txt, subtask2_02.txt, subtask2_03.txt, subtask2_04.txt, subtask2_05.txt, subtask2_06.txt, subtask2_07.txt, subtask2_08.txt, subtask2_09.txt, subtask2_10.txt, subtask2_11.txt, subtask2_12.txt
Case Name Status Exec Time Memory
subtask0_sample_01.txt AC 18 ms 800 KB
subtask0_sample_02.txt AC 18 ms 800 KB
subtask0_sample_03.txt AC 18 ms 800 KB
subtask0_sample_04.txt AC 17 ms 792 KB
subtask0_sample_05.txt AC 18 ms 796 KB
subtask1_01.txt AC 18 ms 920 KB
subtask1_02.txt AC 19 ms 800 KB
subtask1_03.txt AC 18 ms 796 KB
subtask1_04.txt AC 16 ms 928 KB
subtask1_05.txt AC 18 ms 800 KB
subtask1_06.txt AC 18 ms 796 KB
subtask1_07.txt AC 18 ms 800 KB
subtask1_08.txt AC 16 ms 924 KB
subtask1_09.txt AC 19 ms 800 KB
subtask1_10.txt AC 18 ms 800 KB
subtask1_11.txt AC 18 ms 800 KB
subtask1_12.txt AC 19 ms 796 KB
subtask1_13.txt AC 19 ms 796 KB
subtask2_01.txt AC 22 ms 1056 KB
subtask2_02.txt AC 20 ms 960 KB
subtask2_03.txt AC 20 ms 1052 KB
subtask2_04.txt AC 22 ms 1040 KB
subtask2_05.txt AC 22 ms 1056 KB
subtask2_06.txt AC 21 ms 1052 KB
subtask2_07.txt AC 20 ms 924 KB
subtask2_08.txt AC 22 ms 1052 KB
subtask2_09.txt AC 18 ms 916 KB
subtask2_10.txt AC 18 ms 924 KB
subtask2_11.txt AC 18 ms 888 KB
subtask2_12.txt AC 18 ms 924 KB