# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
927286 |
2024-02-14T15:37:58 Z |
vjudge1 |
Martian DNA (BOI18_dna) |
C++17 |
|
44 ms |
14432 KB |
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC target("popcnt")
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pb push_back
#define emb emplace_back
#define emc emplace
#define pii pair<int,int>
#define pll pair<ll,ll>
#define F first
#define S second
template <class type_key, class type_val>
using um = unordered_map<type_key, type_val>;
template <class T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
signed main(void)
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n, k, R;
cin >> n >> k >> R;
int a[n+1];
vector<vector<int>> pos(k+1);
vector<int> need(k+1, 0);
vector<int> rt(k+1, 0);
vector<int> lt(k+1, 0);
for( int i = 1; i <= n; i++ ) {
cin >> a[i];
pos[a[i]].pb(i);
}
pii Q[R+1];
int r = 0;
for( int i = 1; i <= R; i++ ) {
cin >> Q[i].F >> Q[i].S;
if( pos[Q[i].F].size() < Q[i].S ) {
cout << "impossible";
return 0;
}
r = max(r, pos[Q[i].F][Q[i].S-1]);
need[Q[i].F] = Q[i].S;
lt[Q[i].F] = 0;
}
for( int i = 1; i <= R; i++ ) {
rt[Q[i].F] = Q[i].S-1;
}
int mn = r;
for( int l = 1; l <= n; l++ ) {
if( need[a[l]] ) {
lt[a[l]]++;
rt[a[l]]++;
if( rt[a[l]] >= pos[a[l]].size() ) break;
r = max(r, pos[a[l]][rt[a[l]]]);
}
mn = min(mn, r-l);
}
cout << mn;
return 0;
}
Compilation message
dna.cpp: In function 'int main()':
dna.cpp:46:36: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
46 | if( pos[Q[i].F].size() < Q[i].S ) {
| ^
dna.cpp:63:32: warning: comparison of integer expressions of different signedness: '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
63 | if( rt[a[l]] >= pos[a[l]].size() ) break;
# |
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 |
0 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 |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
604 KB |
Output is correct |
4 |
Correct |
1 ms |
604 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
344 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 |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 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 |
600 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
2396 KB |
Output is correct |
2 |
Correct |
10 ms |
2524 KB |
Output is correct |
3 |
Correct |
10 ms |
2140 KB |
Output is correct |
4 |
Correct |
11 ms |
2396 KB |
Output is correct |
5 |
Correct |
20 ms |
6520 KB |
Output is correct |
6 |
Correct |
9 ms |
2396 KB |
Output is correct |
7 |
Correct |
11 ms |
2140 KB |
Output is correct |
8 |
Correct |
40 ms |
14432 KB |
Output is correct |
9 |
Correct |
16 ms |
2648 KB |
Output is correct |
10 |
Correct |
9 ms |
2300 KB |
Output is correct |
11 |
Correct |
0 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 |
604 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
544 KB |
Output is correct |
17 |
Correct |
0 ms |
348 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 |
344 KB |
Output is correct |
22 |
Correct |
1 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 |
34 ms |
6952 KB |
Output is correct |
2 |
Correct |
29 ms |
5724 KB |
Output is correct |
3 |
Correct |
24 ms |
5468 KB |
Output is correct |
4 |
Correct |
10 ms |
2296 KB |
Output is correct |
5 |
Correct |
32 ms |
8532 KB |
Output is correct |
6 |
Correct |
44 ms |
13916 KB |
Output is correct |
7 |
Correct |
17 ms |
2908 KB |
Output is correct |
8 |
Correct |
23 ms |
3592 KB |
Output is correct |
9 |
Correct |
9 ms |
2392 KB |
Output is correct |
10 |
Correct |
10 ms |
2328 KB |
Output is correct |
11 |
Correct |
10 ms |
2140 KB |
Output is correct |
12 |
Correct |
9 ms |
2396 KB |
Output is correct |
13 |
Correct |
21 ms |
6492 KB |
Output is correct |
14 |
Correct |
9 ms |
2396 KB |
Output is correct |
15 |
Correct |
11 ms |
2156 KB |
Output is correct |
16 |
Correct |
36 ms |
14416 KB |
Output is correct |
17 |
Correct |
19 ms |
2908 KB |
Output is correct |
18 |
Correct |
11 ms |
2300 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 |
604 KB |
Output is correct |
22 |
Correct |
1 ms |
604 KB |
Output is correct |
23 |
Correct |
1 ms |
348 KB |
Output is correct |
24 |
Correct |
0 ms |
348 KB |
Output is correct |
25 |
Correct |
0 ms |
348 KB |
Output is correct |
26 |
Correct |
0 ms |
348 KB |
Output is correct |
27 |
Correct |
0 ms |
348 KB |
Output is correct |
28 |
Correct |
0 ms |
344 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 |
0 ms |
348 KB |
Output is correct |