답안 #209209

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
209209 2020-03-13T12:24:58 Z mieszko11b 가로등 (APIO19_street_lamps) C++14
20 / 100
5 ms 380 KB
#include <bits/stdc++.h>

using namespace std;

int n, q;
char c[107][107];

int main() {
	scanf("%d%d", &n, &q);
	if(n <= 100 && q <= 100) {
		scanf(" %s", c[0] + 1);
		for(int i = 1 ; i <= q ; i++) {
			char comm[10];
			
			for(int j = 1 ; j <= n ; j++)	
				c[i][j] = c[i - 1][j];
			
			scanf(" %s", comm);
			if(comm[0] == 'q') {
				int a, b;
				scanf("%d%d", &a, &b);
				int res = 0;
				for(int j = 0 ; j < i ; j++) {
					bool ok = true;
					for(int k = a ; k < b ; k++)
						if(c[j][k] == '0')
							ok = false;
					if(ok) res++;
				}
				printf("%d\n", res);
			} else {
				int w;
				scanf("%d", &w);
				
				if(c[i][w] == '0') c[i][w] = '1';
				else c[i][w] = '0';
			}
		}
	}
	return 0;
}

Compilation message

street_lamps.cpp: In function 'int main()':
street_lamps.cpp:9:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &n, &q);
  ~~~~~^~~~~~~~~~~~~~~~
street_lamps.cpp:11:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf(" %s", c[0] + 1);
   ~~~~~^~~~~~~~~~~~~~~~~
street_lamps.cpp:18:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf(" %s", comm);
    ~~~~~^~~~~~~~~~~~~
street_lamps.cpp:21:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d", &a, &b);
     ~~~~~^~~~~~~~~~~~~~~~
street_lamps.cpp:33:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &w);
     ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 380 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 380 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Incorrect 5 ms 256 KB Output isn't correct
9 Halted 0 ms 0 KB -