Submission #62281238


Source Code Expand

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

const int MOD=1e9+7;


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
	
	int n;
	cin>>n;
	
	string s;
	cin>>s;
	int sz=s.size();
	vector<int> dpprev0(sz), dpprev1(sz), dpcur0, dpcur1;
	
	for(int i=0; i<sz; i++){
		dpprev0[i]=s[i]=='0';
		dpprev1[i]=s[i]=='1';
		
	}
	vector<int> temp(3);
	
	for(int i=0; i<n; i++){
		dpcur0.clear();
		dpcur1.clear();
		int sz=dpprev0.size();
		for(int i=0; i<sz; i+=3){
			
			for(int j=0; j<3; j++){
				temp[j]=dpprev0[i+j];
			}
			sort(temp.begin(),temp.end());
			dpcur0.push_back(temp[0]+temp[1]);
			
			for(int j=0; j<3; j++){
				temp[j]=dpprev1[i+j];
			}
			sort(temp.begin(),temp.end());
			dpcur1.push_back(temp[0]+temp[1]);
			
		}
		dpprev0=dpcur0;
		dpprev1=dpcur1;
		
		
		
	}
	cout<<abs(dpcur0[0]-dpcur1[0]); 
	
	
	
	
    
    return 0;
}

Submission Info

Submission Time
Task E - Hierarchical Majority Vote
User usernameson
Language C++ 20 (gcc 12.2)
Score 450
Code Size 913 Byte
Status AC
Exec Time 37 ms
Memory 24692 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 450 / 450
Status
AC × 2
AC × 32
Set Name Test Cases
Sample 00_sample_01.txt, 00_sample_02.txt
All 00_sample_01.txt, 00_sample_02.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 01_random_20.txt, 02_handmade_01.txt, 02_handmade_02.txt, 02_handmade_03.txt, 02_handmade_04.txt, 02_handmade_05.txt, 02_handmade_06.txt, 02_handmade_07.txt, 02_handmade_08.txt, 02_handmade_09.txt, 02_handmade_10.txt
Case Name Status Exec Time Memory
00_sample_01.txt AC 1 ms 3460 KiB
00_sample_02.txt AC 1 ms 3384 KiB
01_random_01.txt AC 2 ms 3596 KiB
01_random_02.txt AC 37 ms 24540 KiB
01_random_03.txt AC 1 ms 3444 KiB
01_random_04.txt AC 37 ms 24640 KiB
01_random_05.txt AC 2 ms 4116 KiB
01_random_06.txt AC 34 ms 24608 KiB
01_random_07.txt AC 5 ms 5344 KiB
01_random_08.txt AC 37 ms 24624 KiB
01_random_09.txt AC 1 ms 3476 KiB
01_random_10.txt AC 37 ms 24580 KiB
01_random_11.txt AC 1 ms 3384 KiB
01_random_12.txt AC 27 ms 24692 KiB
01_random_13.txt AC 1 ms 3424 KiB
01_random_14.txt AC 36 ms 24456 KiB
01_random_15.txt AC 1 ms 3628 KiB
01_random_16.txt AC 36 ms 24640 KiB
01_random_17.txt AC 2 ms 3548 KiB
01_random_18.txt AC 37 ms 24464 KiB
01_random_19.txt AC 1 ms 3528 KiB
01_random_20.txt AC 37 ms 24684 KiB
02_handmade_01.txt AC 29 ms 24596 KiB
02_handmade_02.txt AC 29 ms 24568 KiB
02_handmade_03.txt AC 27 ms 24456 KiB
02_handmade_04.txt AC 30 ms 24604 KiB
02_handmade_05.txt AC 29 ms 24564 KiB
02_handmade_06.txt AC 31 ms 24624 KiB
02_handmade_07.txt AC 31 ms 24644 KiB
02_handmade_08.txt AC 30 ms 24584 KiB
02_handmade_09.txt AC 30 ms 24588 KiB
02_handmade_10.txt AC 27 ms 24536 KiB