답안 #1028834

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1028834 2024-07-20T09:21:05 Z hasan2006 Martian DNA (BOI18_dna) C++17
100 / 100
172 ms 149692 KB
#include <bits/stdc++.h>

using namespace std;

#define TL ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define rall(s) s.rbegin(),s.rend()
#define all(s) s.begin(),s.end()
#define pb push_back
#define se second
#define fi first
#define ll long long
#define ld long double
#define YES cout<<"YES\n"
#define Yes cout<<"Yes\n"
#define yes cout<<"yes\n"
#define NO cout<<"NO\n"
#define No cout<<"No\n"
#define no cout<<"no\n"


const int N = 2e5 + 9 , mod = 1e9 + 7;
ll  dp[N] , a[N] ,c[N] ,  b[N] , p[N];
deque<int>d[N];
void solve()
{
    ll n , q , i , j ,l ,r , x , y , s = 0 , f , k , m , mn = 1e18, mx = 0 ;
    cin>>n>>k>>m;
    for(i = 1; i <= n; i++){
        cin>>a[i];
    }
    for(i = 1; i <= m; i++){
        cin>>l>>r;
        b[l] = r;
    }
    set<ll>st , st1;
    for(i = 1; i <= n; i++){
        d[a[i]].pb(i);
        st.insert(i);
        if(d[a[i]].size() > b[a[i]]){
            st.erase(d[a[i]].front());
            d[a[i]].pop_front();
        }
        if(d[a[i]].size() == b[a[i]] && b[a[i]])
            st1.insert(a[i]);
        if(st1.size() == m)
            mn = min(mn , i - *st.begin() + 1);
    }
    if(mn == 1e18){
        cout<<"impossible";
        return;
    }
    cout<<mn<<"\n";
}


int main(){
    TL;
    /*#ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif*/
    int t = 1;
//    cin>>t;
    while(t--)
     {
        solve();
     }
}
// Author : حسن

Compilation message

dna.cpp: In function 'void solve()':
dna.cpp:39:27: warning: comparison of integer expressions of different signedness: 'std::deque<int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   39 |         if(d[a[i]].size() > b[a[i]]){
      |            ~~~~~~~~~~~~~~~^~~~~~~~~
dna.cpp:43:27: warning: comparison of integer expressions of different signedness: 'std::deque<int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   43 |         if(d[a[i]].size() == b[a[i]] && b[a[i]])
      |            ~~~~~~~~~~~~~~~^~~~~~~~~~
dna.cpp:45:23: warning: comparison of integer expressions of different signedness: 'std::set<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   45 |         if(st1.size() == m)
      |            ~~~~~~~~~~~^~~~
dna.cpp:26:12: warning: unused variable 'q' [-Wunused-variable]
   26 |     ll n , q , i , j ,l ,r , x , y , s = 0 , f , k , m , mn = 1e18, mx = 0 ;
      |            ^
dna.cpp:26:20: warning: unused variable 'j' [-Wunused-variable]
   26 |     ll n , q , i , j ,l ,r , x , y , s = 0 , f , k , m , mn = 1e18, mx = 0 ;
      |                    ^
dna.cpp:26:30: warning: unused variable 'x' [-Wunused-variable]
   26 |     ll n , q , i , j ,l ,r , x , y , s = 0 , f , k , m , mn = 1e18, mx = 0 ;
      |                              ^
dna.cpp:26:34: warning: unused variable 'y' [-Wunused-variable]
   26 |     ll n , q , i , j ,l ,r , x , y , s = 0 , f , k , m , mn = 1e18, mx = 0 ;
      |                                  ^
dna.cpp:26:38: warning: unused variable 's' [-Wunused-variable]
   26 |     ll n , q , i , j ,l ,r , x , y , s = 0 , f , k , m , mn = 1e18, mx = 0 ;
      |                                      ^
dna.cpp:26:46: warning: unused variable 'f' [-Wunused-variable]
   26 |     ll n , q , i , j ,l ,r , x , y , s = 0 , f , k , m , mn = 1e18, mx = 0 ;
      |                                              ^
dna.cpp:26:69: warning: unused variable 'mx' [-Wunused-variable]
   26 |     ll n , q , i , j ,l ,r , x , y , s = 0 , f , k , m , mn = 1e18, mx = 0 ;
      |                                                                     ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 56 ms 134992 KB Output is correct
2 Correct 61 ms 134996 KB Output is correct
3 Correct 65 ms 135028 KB Output is correct
4 Correct 61 ms 134988 KB Output is correct
5 Correct 62 ms 135096 KB Output is correct
6 Correct 63 ms 134996 KB Output is correct
7 Correct 62 ms 134996 KB Output is correct
8 Correct 77 ms 135088 KB Output is correct
9 Correct 61 ms 135096 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 75 ms 134992 KB Output is correct
2 Correct 64 ms 135060 KB Output is correct
3 Correct 61 ms 135060 KB Output is correct
4 Correct 62 ms 134996 KB Output is correct
5 Correct 61 ms 134996 KB Output is correct
6 Correct 63 ms 134992 KB Output is correct
7 Correct 57 ms 135004 KB Output is correct
8 Correct 59 ms 134996 KB Output is correct
9 Correct 59 ms 134996 KB Output is correct
10 Correct 57 ms 134892 KB Output is correct
11 Correct 61 ms 135096 KB Output is correct
12 Correct 59 ms 134996 KB Output is correct
13 Correct 61 ms 134860 KB Output is correct
14 Correct 62 ms 134996 KB Output is correct
15 Correct 61 ms 134972 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 93 ms 141648 KB Output is correct
2 Correct 83 ms 139088 KB Output is correct
3 Correct 88 ms 137040 KB Output is correct
4 Correct 102 ms 140112 KB Output is correct
5 Correct 98 ms 137812 KB Output is correct
6 Correct 101 ms 147280 KB Output is correct
7 Correct 106 ms 137300 KB Output is correct
8 Correct 107 ms 137812 KB Output is correct
9 Correct 87 ms 137588 KB Output is correct
10 Correct 99 ms 140884 KB Output is correct
11 Correct 73 ms 134996 KB Output is correct
12 Correct 57 ms 135144 KB Output is correct
13 Correct 59 ms 134996 KB Output is correct
14 Correct 83 ms 135000 KB Output is correct
15 Correct 62 ms 135160 KB Output is correct
16 Correct 69 ms 134992 KB Output is correct
17 Correct 76 ms 135100 KB Output is correct
18 Correct 57 ms 134992 KB Output is correct
19 Correct 62 ms 135104 KB Output is correct
20 Correct 58 ms 135044 KB Output is correct
21 Correct 63 ms 134960 KB Output is correct
22 Correct 63 ms 135100 KB Output is correct
23 Correct 61 ms 134992 KB Output is correct
24 Correct 66 ms 135084 KB Output is correct
25 Correct 65 ms 134996 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 172 ms 146512 KB Output is correct
2 Correct 158 ms 144208 KB Output is correct
3 Correct 137 ms 140088 KB Output is correct
4 Correct 76 ms 137040 KB Output is correct
5 Correct 123 ms 147024 KB Output is correct
6 Correct 165 ms 149692 KB Output is correct
7 Correct 149 ms 141784 KB Output is correct
8 Correct 137 ms 140676 KB Output is correct
9 Correct 91 ms 141652 KB Output is correct
10 Correct 107 ms 139088 KB Output is correct
11 Correct 96 ms 136960 KB Output is correct
12 Correct 97 ms 140116 KB Output is correct
13 Correct 97 ms 137816 KB Output is correct
14 Correct 94 ms 147284 KB Output is correct
15 Correct 91 ms 137300 KB Output is correct
16 Correct 104 ms 137836 KB Output is correct
17 Correct 84 ms 137556 KB Output is correct
18 Correct 106 ms 140812 KB Output is correct
19 Correct 73 ms 135184 KB Output is correct
20 Correct 63 ms 135452 KB Output is correct
21 Correct 61 ms 134996 KB Output is correct
22 Correct 63 ms 134996 KB Output is correct
23 Correct 61 ms 134996 KB Output is correct
24 Correct 69 ms 134992 KB Output is correct
25 Correct 68 ms 135216 KB Output is correct
26 Correct 59 ms 135040 KB Output is correct
27 Correct 60 ms 134976 KB Output is correct
28 Correct 62 ms 135000 KB Output is correct
29 Correct 58 ms 134992 KB Output is correct
30 Correct 58 ms 134996 KB Output is correct
31 Correct 60 ms 135048 KB Output is correct
32 Correct 70 ms 134996 KB Output is correct
33 Correct 65 ms 134992 KB Output is correct