Submission #3011743


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;
    q.push(s);
    int ans;
    while(1){

        string t = q.front();
        q.pop();

        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()){
                    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 957 Byte
Status RE
Exec Time 2878 ms
Memory 794304 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 700
Status
AC × 2
AC × 4
TLE × 8
RE × 27
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 2533 ms -593908 KB
001.txt TLE 2784 ms -593232 KB
002.txt RE 1637 ms -593212 KB
003.txt RE 1628 ms -593324 KB
004.txt RE 1757 ms -592948 KB
005.txt RE 1726 ms -592920 KB
006.txt RE 1733 ms -592832 KB
007.txt RE 1603 ms -592888 KB
008.txt RE 1901 ms -592680 KB
009.txt RE 1741 ms -592808 KB
010.txt AC 28 ms 2808 KB
011.txt RE 1637 ms -592736 KB
012.txt RE 1739 ms -594012 KB
013.txt RE 1852 ms -592844 KB
014.txt RE 1641 ms -592776 KB
015.txt RE 1725 ms -592860 KB
016.txt RE 1650 ms -592780 KB
017.txt RE 1840 ms -592744 KB
018.txt RE 1633 ms -592896 KB
019.txt TLE 2379 ms -592576 KB
020.txt AC 28 ms 2808 KB
021.txt TLE 2103 ms 2732 KB
022.txt TLE 2153 ms 794304 KB
023.txt TLE 2236 ms -2007448 KB
024.txt TLE 2300 ms -1026760 KB
025.txt TLE 2878 ms -592768 KB
026.txt RE 2066 ms -592904 KB
027.txt RE 1904 ms -592800 KB
028.txt RE 1818 ms -592640 KB
029.txt RE 1772 ms -593260 KB
030.txt RE 1767 ms -592840 KB
031.txt RE 1741 ms -592864 KB
032.txt RE 1758 ms -592708 KB
033.txt RE 1639 ms -592828 KB
034.txt RE 1628 ms -592920 KB
035.txt RE 1750 ms -592788 KB
036.txt RE 1767 ms -592788 KB
example0.txt AC 10 ms 1908 KB
example1.txt AC 9 ms 1536 KB