Submission #433688

# Submission time Handle Problem Language Result Execution time Memory
433688 2021-06-20T09:31:04 Z JeanBombeur Street Lamps (APIO19_street_lamps) C++17
20 / 100
255 ms 19312 KB
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;

//   <|°_°|>

const int MAX_LAMPES = (300 * 1000);

bool State[MAX_LAMPES];

char Mot[MAX_LAMPES + 1];

vector <int> Dates[MAX_LAMPES];

int nbLampes, nbRequetes;

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

void Solve() {
	for (int i = 1; i <= nbRequetes; i ++)
	{
		int a, b;
		scanf("%s %d", Mot, &a);
		a --;
		Dates[a].push_back(i);
		if (Mot[0] == 'q')
		{
			scanf("%d", &b);
			b --;
			int sz = (int)Dates[a].size();
			int ans = 0;
			int deb = 1;
			if (!State[a])
				deb ++;
			for (; deb < sz; deb += 2)
			{
				ans += Dates[a][deb] - Dates[a][deb - 1];
			}
			printf("%d\n", ans);
			if (!State[a])
				ans = i - ans;
			Dates[a].clear();
			Dates[a].push_back(0);
			Dates[a].push_back(ans);
			if (!(sz & 1))
				Dates[a].push_back(i);
		}
	}
	return;
}

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

Compilation message

street_lamps.cpp: In function 'void Read()':
street_lamps.cpp:19:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |  scanf("%d %d", &nbLampes, &nbRequetes);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
street_lamps.cpp:20:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |  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:38:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   38 |    scanf("%d", &b);
      |    ~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 7244 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 96 ms 8244 KB Output is correct
2 Correct 100 ms 8232 KB Output is correct
3 Correct 114 ms 8692 KB Output is correct
4 Correct 210 ms 18348 KB Output is correct
5 Correct 231 ms 18556 KB Output is correct
6 Correct 215 ms 18020 KB Output is correct
7 Correct 234 ms 17848 KB Output is correct
8 Correct 255 ms 19312 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 7372 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 7372 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 7244 KB Output isn't correct
2 Halted 0 ms 0 KB -