Submission #433652

#TimeUsernameProblemLanguageResultExecution timeMemory
433652JeanBombeurStreet Lamps (APIO19_street_lamps)C++17
20 / 100
8 ms332 KiB
#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 (stderr)

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);
      |    ~~~~~^~~~~~~~~~
#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...