Submission #3011755


Source Code Expand

#include<bits/stdc++.h>
using namespace std;

int count1(string& s){
    int rec = 0;
    for(auto c : s){
        rec += (c == '1');
    }

    return rec;
}

int main(){
    int n; cin >> n;
    string s; cin >> s;
    set<string> used;
    queue<string> q;
    used.insert(s);
    q.push(s);
    int ans;
    while(1){

        string t = q.front();
        q.pop();
        //cout << t << endl;

        for(int i = 1; i <= n - 2; i++){

            if(t[i - 1] == '1' && t[i] == '0' && t[i + 1] == '1'){

                t[i - 1] = '0';
                t[i] = '1';
                t[i + 1] = '0';
                if(used.find(t) == used.end()){
                    used.insert(t);
                    q.push(t);
                }
                t[i - 1] = '1';
                t[i] = '0';
                t[i + 1] = '1';

            }
        }

        if(q.empty()){
            ans = count1(s) - count1(t);
            break;
        }
    }

    cout << ans << endl;
    return 0;
}

Submission Info

Submission Time
Task D - 101 to 010
User monkukui
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1045 Byte
Status RE
Exec Time 3341 ms
Memory 2031616 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 700
Status
AC × 2
AC × 4
TLE × 34
RE × 1
Set Name Test Cases
Sample example0.txt, example1.txt
All 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, 019.txt, 020.txt, 021.txt, 022.txt, 023.txt, 024.txt, 025.txt, 026.txt, 027.txt, 028.txt, 029.txt, 030.txt, 031.txt, 032.txt, 033.txt, 034.txt, 035.txt, 036.txt, example0.txt, example1.txt
Case Name Status Exec Time Memory
000.txt TLE 2279 ms -1496464 KB
001.txt TLE 2269 ms -1565704 KB
002.txt TLE 2276 ms -1412988 KB
003.txt TLE 2267 ms -1840508 KB
004.txt TLE 2293 ms -1132540 KB
005.txt TLE 2338 ms -596712 KB
006.txt TLE 2274 ms -1505792 KB
007.txt TLE 2262 ms -1620224 KB
008.txt TLE 2256 ms -1789952 KB
009.txt TLE 2317 ms -740092 KB
010.txt AC 21 ms 1796 KB
011.txt TLE 2270 ms -1474172 KB
012.txt TLE 2523 ms -595544 KB
013.txt TLE 2198 ms -595580 KB
014.txt TLE 2526 ms -595484 KB
015.txt TLE 2724 ms -595532 KB
016.txt RE 1996 ms -595736 KB
017.txt TLE 2549 ms -595440 KB
018.txt TLE 3341 ms -595460 KB
019.txt TLE 3184 ms -595180 KB
020.txt AC 29 ms 3320 KB
021.txt TLE 2135 ms 496812 KB
022.txt TLE 2139 ms 560832 KB
023.txt TLE 2170 ms 1087336 KB
024.txt TLE 2185 ms 1322168 KB
025.txt TLE 2184 ms 1311960 KB
026.txt TLE 2211 ms 1756696 KB
027.txt TLE 2229 ms 2031616 KB
028.txt TLE 2267 ms -1509168 KB
029.txt TLE 2275 ms -1382688 KB
030.txt TLE 2270 ms -1436184 KB
031.txt TLE 2262 ms -1578836 KB
032.txt TLE 2251 ms -1790696 KB
033.txt TLE 2265 ms -1566204 KB
034.txt TLE 2297 ms -1026044 KB
035.txt TLE 2352 ms -594960 KB
036.txt TLE 2612 ms -595268 KB
example0.txt AC 11 ms 1780 KB
example1.txt AC 1 ms 256 KB