Submission #975073

#TimeUsernameProblemLanguageResultExecution timeMemory
975073blackslex Martian DNA (BOI18_dna)C++17
100 / 100
41 ms4692 KiB
#include<bits/stdc++.h> using namespace std; int n, k, R, x, y; int main() { scanf("%d %d %d", &n, &k, &R); vector<int> a(n), req(k, -1), cnt(k); for (auto &e: a) scanf("%d", &e); for (int i = 0; i < R; i++) scanf("%d %d", &x, &y), req[x] = y; int cur = 0, ans = 1e9; for (int l = 0, r = 0; l < n; l++) { while (r < n && cur != R) { cnt[a[r]]++; if (cnt[a[r]] == req[a[r]]) cur++; r++; } if (cur == R) ans = min(ans, r - l); if (cnt[a[l]] == req[a[l]]) cur--; cnt[a[l]]--; } if (ans == 1e9) printf("impossible"); else printf("%d", ans); }

Compilation message (stderr)

dna.cpp: In function 'int main()':
dna.cpp:16:13: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   16 |             if (cnt[a[r]] == req[a[r]]) cur++; r++;
      |             ^~
dna.cpp:16:48: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   16 |             if (cnt[a[r]] == req[a[r]]) cur++; r++;
      |                                                ^
dna.cpp:8:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |     scanf("%d %d %d", &n, &k, &R);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
dna.cpp:10:27: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |     for (auto &e: a) scanf("%d", &e);
      |                      ~~~~~^~~~~~~~~~
dna.cpp:11:38: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |     for (int i = 0; i < R; i++) scanf("%d %d", &x, &y), req[x] = y;
      |                                 ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...