제출 #279647

#제출 시각아이디문제언어결과실행 시간메모리
279647Nodir_Bobiev가로등 (APIO19_street_lamps)C++17
20 / 100
110 ms24068 KiB
/* *** 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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...