답안 #927283

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
927283 2024-02-14T15:31:42 Z vjudge1 Martian DNA (BOI18_dna) C++17
16 / 100
47 ms 14456 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++ ) {
            int ps = lower_bound(pos[Q[i].F].begin(), pos[Q[i].F].end(), r) - pos[Q[i].F].begin();
            if( pos[Q[i].F][ps] > r ) ps--;
            rt[Q[i].F] = ps;
      }

      int mn = r;
      for( int l = 1; l <= n; l++ ) {
            if( need[a[l]] ) {
                  lt[a[l]]++;
                  if( rt[a[l]] - lt[a[l]] + 1 < need[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:45:36: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   45 |             if( pos[Q[i].F].size() < Q[i].S ) {
      |                                    ^
dna.cpp:64: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]
   64 |                   if( rt[a[l]] >= pos[a[l]].size() ) break;
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 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 0 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 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 600 KB Output is correct
5 Incorrect 1 ms 348 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 2396 KB Output is correct
2 Correct 10 ms 2328 KB Output is correct
3 Correct 10 ms 2140 KB Output is correct
4 Correct 10 ms 2648 KB Output is correct
5 Correct 20 ms 6492 KB Output is correct
6 Correct 9 ms 2396 KB Output is correct
7 Correct 10 ms 2140 KB Output is correct
8 Correct 28 ms 14456 KB Output is correct
9 Correct 17 ms 2720 KB Output is correct
10 Correct 9 ms 2300 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 604 KB Output is correct
15 Incorrect 1 ms 348 KB Output isn't correct
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 32 ms 7004 KB Output is correct
2 Correct 29 ms 5820 KB Output is correct
3 Correct 30 ms 5580 KB Output is correct
4 Correct 10 ms 2296 KB Output is correct
5 Correct 23 ms 8352 KB Output is correct
6 Incorrect 47 ms 13992 KB Output isn't correct
7 Halted 0 ms 0 KB -