Submission #279647

# Submission time Handle Problem Language Result Execution time Memory
279647 2020-08-22T08:59:13 Z Nodir_Bobiev Street Lamps (APIO19_street_lamps) C++17
20 / 100
110 ms 24068 KB
/*  
*** In the name of Allah, the most Gracious and the most Merciful.***
*/
# include <bits/stdc++.h>
# define FILE
using namespace std;

const int N = 3e5 + 100;
int n, q;
bool sub2 = true;
string s;
vector < vector < int > > qry;

void Subtask1(){
	//cout << "Subtask1" << endl;
	int cnt[111][111] = {};
	for( int i = 1; i <= n+1; i ++ ){
		cnt[0][i] = (s[i] == '1');
		cnt[0][i] += cnt[0][i-1];
	}
	int qnt = 0;
	for( auto qr: qry){
		//cout << qr.size() << endl;
		if( qr.size() == 1 ){
			s[qr[0]] = char(48 + 49 - s[qr[0]]);
		}else{
			int ans = 0;
			for( int i = 0; i <= qnt; i ++ ){

				if( cnt[i][qr[1]-1] - cnt[i][qr[0]-1] == qr[1] - qr[0] )
					ans ++;
			}
			cout << ans << endl;
		}
		qnt ++;
		for( int i = 1; i <= n+1; i ++ ){
			cnt[qnt][i] = (s[i] == '1');
			cnt[qnt][i] += cnt[qnt][i-1];
		}
	}
	exit( 0 );
}
void Subtask2(){
	exit(0);
}


int main(){
    # ifdef FILEs
        freopen( "input.txt", "r", stdin );
        freopen( "output.txt", "w", stdout );
    # endif
    ios_base::sync_with_stdio(false);
    cin >> n >> q;
    cin >> s;
    s = '0' + s;
    for( int i = 1; i <= q; i ++ ){
    	string ssss; cin >> ssss;
    	if( ssss == "query"){
    		int a, b; cin >> a >> b;
    		qry.push_back({a,b});
    		if( b-a != 1 )sub2 = false;
    	}else{
    		int a; cin >> a;
    		qry.push_back({a});
    	}

    }
    if( n <= 100 && q <= 100 ){
    	Subtask1();
    }
    if( sub2 ){
    	Subtask2();
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 110 ms 24068 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 512 KB Output is correct
8 Incorrect 110 ms 24068 KB Output isn't correct
9 Halted 0 ms 0 KB -