Submission #975073

# Submission time Handle Problem Language Result Execution time Memory
975073 2024-05-04T11:33:20 Z blackslex Martian DNA (BOI18_dna) C++17
100 / 100
41 ms 4692 KB
#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

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 time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 504 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 1372 KB Output is correct
2 Correct 14 ms 1596 KB Output is correct
3 Correct 14 ms 1624 KB Output is correct
4 Correct 14 ms 1624 KB Output is correct
5 Correct 19 ms 3132 KB Output is correct
6 Correct 14 ms 1372 KB Output is correct
7 Correct 13 ms 1596 KB Output is correct
8 Correct 18 ms 4028 KB Output is correct
9 Correct 18 ms 2140 KB Output is correct
10 Correct 14 ms 1368 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 604 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 27 ms 3412 KB Output is correct
2 Correct 24 ms 3164 KB Output is correct
3 Correct 20 ms 2908 KB Output is correct
4 Correct 15 ms 1372 KB Output is correct
5 Correct 30 ms 3924 KB Output is correct
6 Correct 41 ms 4692 KB Output is correct
7 Correct 16 ms 2136 KB Output is correct
8 Correct 18 ms 2396 KB Output is correct
9 Correct 13 ms 1372 KB Output is correct
10 Correct 14 ms 1624 KB Output is correct
11 Correct 15 ms 1628 KB Output is correct
12 Correct 14 ms 1628 KB Output is correct
13 Correct 19 ms 2908 KB Output is correct
14 Correct 13 ms 1372 KB Output is correct
15 Correct 14 ms 1628 KB Output is correct
16 Correct 18 ms 3932 KB Output is correct
17 Correct 15 ms 2140 KB Output is correct
18 Correct 13 ms 1620 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 600 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 1 ms 348 KB Output is correct