답안 #433652

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
433652 2021-06-20T09:15:23 Z JeanBombeur 가로등 (APIO19_street_lamps) C++17
20 / 100
8 ms 332 KB
#include <iostream>
#include <cstdio>
using namespace std;

//   <|°_°|>

const int MAX_LAMPES = (101);

bool State[MAX_LAMPES][MAX_LAMPES];

char Mot[MAX_LAMPES + 1];

int nbLampes, nbRequetes;

void Read() {
	scanf("%d %d", &nbLampes, &nbRequetes);
	scanf("%s", Mot);
	for (int i = 0; i < nbLampes; i ++)
	{
		State[0][i] = Mot[i] == '1';
	}
	return;
}

void Solve() {
	for (int i = 1; i <= nbRequetes; i ++)
	{
		for (int j = 0; j < nbLampes; j ++)
		{
			State[i][j] = State[i - 1][j];
		}
		int a, b;
		scanf("%s %d", Mot, &a);
		a --;
		if (Mot[0] == 't')
			State[i][a] ^= 1;
		else
		{
			scanf("%d", &b);
			b --;
			int ans = 0;
			for (int t = 0; t < i; t ++)
			{
				bool path = true;
				for (int d = a; d < b; d ++)
				{
					path &= State[t][d];
				}
				if (path)
					ans ++;
			}
			printf("%d\n", ans);
		}
	}
	return;
}

int main() {
	Read();
	Solve();
	return 0;
}

Compilation message

street_lamps.cpp: In function 'void Read()':
street_lamps.cpp:16:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |  scanf("%d %d", &nbLampes, &nbRequetes);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
street_lamps.cpp:17:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |  scanf("%s", Mot);
      |  ~~~~~^~~~~~~~~~~
street_lamps.cpp: In function 'void Solve()':
street_lamps.cpp:33:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |   scanf("%s %d", Mot, &a);
      |   ~~~~~^~~~~~~~~~~~~~~~~~
street_lamps.cpp:39:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   39 |    scanf("%d", &b);
      |    ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 332 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 332 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 8 ms 304 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Runtime error 1 ms 332 KB Execution killed with signal 11
9 Halted 0 ms 0 KB -