Submission #1025400

# Submission time Handle Problem Language Result Execution time Memory
1025400 2024-07-17T01:40:07 Z vjudge1 Martian DNA (BOI18_dna) C++17
68 / 100
2000 ms 15196 KB
#include <bits/stdc++.h>
#define int long long
#define INF LLONG_MAX
#define pii pair<int, int>
using namespace std;

int32_t main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     cout.tie(NULL);

     int n, k, r;
     cin >> n >> k >> r;
     vector<vector<int>> pos(k);
     vector<int> dna(n);
     for (int i = 0; i < n; i++)
     {
          cin >> dna[i];
          pos[dna[i]].push_back(i);
     }
     vector<int> maxx(n, 0);
     for (int i = 0; i < r; i++)
     {
          int nucleo, num;
          cin >> nucleo >> num;
          if (pos[nucleo].size() < num)
          {
               cout << "impossible" << endl;
               return 0;
          }
          for (int j = 0; j < n; j++)
          {
               int idx = lower_bound(pos[nucleo].begin(), pos[nucleo].end(), j) - pos[nucleo].begin();
               if (idx + num - 1 < pos[nucleo].size())
                    maxx[j] = max(maxx[j], pos[nucleo][idx + num - 1] - j + 1);
               else
                    maxx[j] = INF;
          }
     }
     cout << *min_element(maxx.begin(), maxx.end()) << endl;

     return 0;
}

Compilation message

dna.cpp: In function 'int32_t main()':
dna.cpp:27:34: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   27 |           if (pos[nucleo].size() < num)
      |               ~~~~~~~~~~~~~~~~~~~^~~~~
dna.cpp:35:34: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |                if (idx + num - 1 < pos[nucleo].size())
      |                    ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 344 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 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 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 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 660 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 1 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
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 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 44 ms 5696 KB Output is correct
2 Correct 17 ms 5904 KB Output is correct
3 Correct 43 ms 5716 KB Output is correct
4 Correct 44 ms 5656 KB Output is correct
5 Correct 29 ms 9176 KB Output is correct
6 Correct 40 ms 5820 KB Output is correct
7 Correct 12 ms 5980 KB Output is correct
8 Correct 38 ms 15196 KB Output is correct
9 Correct 29 ms 6996 KB Output is correct
10 Correct 41 ms 5792 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 604 KB Output is correct
14 Correct 1 ms 620 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 604 KB Output is correct
18 Correct 0 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 0 ms 348 KB Output is correct
22 Correct 1 ms 344 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 Execution timed out 2062 ms 9300 KB Time limit exceeded
2 Halted 0 ms 0 KB -