Submission #1031912

# Submission time Handle Problem Language Result Execution time Memory
1031912 2024-07-23T08:40:17 Z KasymK Street Lamps (APIO19_street_lamps) C++17
20 / 100
1426 ms 4592 KB
#include "bits/stdc++.h"
using namespace std;
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define ll long long
#define pb push_back
#define pii pair<int, int>
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
const int MOD = 1e9+7;
const int N = 1e2+5;
int par[N], ans[N][N];

int main(){
	// freopen("file.txt", "r", stdin);
	int n, q;
	scanf("%d%d", &n, &q);
	string s;
	cin >> s;
	for(int i = 0; i < n; ++i)
		par[i+1] = par[i]+(s[i]-'0');
	for(int i = 0; i < n; ++i)
		for(int j = i+1; j <= n; ++j)
			ans[i][j] = (par[j]-par[i] == j-i);
	while(q--){
		string t;
		cin >> t;
		if (t == "query"){
			int a, b;
			scanf("%d%d", &a, &b), a--, b--;
			printf("%d\n", ans[a][b]);
		}
		else{
			int i;
			scanf("%d", &i), i--;
			s[i] = (s[i] == '0' ? '1' : '0');
		}
		par[0] = 0;
		for(int i = 0; i < n; ++i)
			par[i+1] = par[i]+(s[i]-'0');
		for(int i = 0; i < n; ++i)
			for(int j = i+1; j <= n; ++j)
				ans[i][j] += (par[j]-par[i] == j-i);
	}	
	return 0;
}

Compilation message

street_lamps.cpp: In function 'int main()':
street_lamps.cpp:18:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |  scanf("%d%d", &n, &q);
      |  ~~~~~^~~~~~~~~~~~~~~~
street_lamps.cpp:31:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |    scanf("%d%d", &a, &b), a--, b--;
      |    ~~~~~^~~~~~~~~~~~~~~~
street_lamps.cpp:36:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 |    scanf("%d", &i), i--;
      |    ~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 352 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1426 ms 4592 KB Output is correct
2 Runtime error 1 ms 600 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 604 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 604 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 352 KB Output is correct
8 Correct 1426 ms 4592 KB Output is correct
9 Runtime error 1 ms 600 KB Execution killed with signal 11
10 Halted 0 ms 0 KB -