Submission #458062

# Submission time Handle Problem Language Result Execution time Memory
458062 2021-08-08T00:02:30 Z ZaZo_ Martian DNA (BOI18_dna) C++14
100 / 100
662 ms 19196 KB
//Sorry but iam targeting IOI :))
//NEVER LOSE HOPE
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#include <bits/stdc++.h>
#define endl "\n"
#define ceil(a,b)   (a+(b-1))/b
#define all(v) v.begin(),v.end()
#define int long long int
#define Hidden ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int N=3e4+10,mod = 1e9+7;
int32_t main(){
  int n,k,rr;
  cin>>n>>k>>rr;
  int arr[n];
  map<int,int>mp,req,dif;
  set<int>st;
  for(int i = 0 ; i < n ; i ++)
  {
    cin>>arr[i];
  }
  int flg=0;
  for(int i = 0 ; i < rr ; i ++)
  {
    int x,y;
    cin>>x>>y;
    if(mp[x]<y) flg=1;
    req[x]=y;
  }
  int l=0,r=0,ans=INT_MAX,cnt=0;
  while(l<=r)
  {
    while(r<n && cnt<req.size() )
    {
      mp[arr[r]]++;
      if(req.count(arr[r]) && mp[arr[r]]==req[arr[r]]) cnt++;
      r++;
    }
    if(cnt==req.size())
      ans=min(ans,r-l);
    mp[arr[l]]--;
    if(req.count(arr[l])&&req[arr[l]]>mp[arr[l]]) cnt--;
    if(mp[arr[l]]==0) mp.erase(arr[l]);
    l++;
  }
  if(ans==INT_MAX)
  {
    cout<<"impossible"<<endl;
    return 0;
  }
  cout<<ans<<endl;
}

Compilation message

dna.cpp: In function 'int32_t main()':
dna.cpp:34:21: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::map<long long int, long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |     while(r<n && cnt<req.size() )
      |                  ~~~^~~~~~~~~~~
dna.cpp:40:11: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::map<long long int, long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |     if(cnt==req.size())
      |        ~~~^~~~~~~~~~~~
dna.cpp:23:7: warning: variable 'flg' set but not used [-Wunused-but-set-variable]
   23 |   int flg=0;
      |       ^~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 4 ms 460 KB Output is correct
4 Correct 4 ms 460 KB Output is correct
5 Correct 3 ms 332 KB Output is correct
6 Correct 2 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 46 ms 1836 KB Output is correct
2 Correct 42 ms 1740 KB Output is correct
3 Correct 48 ms 1740 KB Output is correct
4 Correct 57 ms 1740 KB Output is correct
5 Correct 257 ms 6812 KB Output is correct
6 Correct 51 ms 1828 KB Output is correct
7 Correct 66 ms 1740 KB Output is correct
8 Correct 258 ms 11684 KB Output is correct
9 Correct 137 ms 2332 KB Output is correct
10 Correct 60 ms 1740 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 4 ms 460 KB Output is correct
14 Correct 4 ms 460 KB Output is correct
15 Correct 3 ms 332 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 0 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 0 ms 204 KB Output is correct
22 Correct 0 ms 204 KB Output is correct
23 Correct 0 ms 204 KB Output is correct
24 Correct 0 ms 204 KB Output is correct
25 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 551 ms 11848 KB Output is correct
2 Correct 426 ms 9392 KB Output is correct
3 Correct 324 ms 6724 KB Output is correct
4 Correct 48 ms 1828 KB Output is correct
5 Correct 582 ms 13192 KB Output is correct
6 Correct 662 ms 19196 KB Output is correct
7 Correct 252 ms 2884 KB Output is correct
8 Correct 292 ms 4036 KB Output is correct
9 Correct 46 ms 1860 KB Output is correct
10 Correct 42 ms 1824 KB Output is correct
11 Correct 50 ms 1832 KB Output is correct
12 Correct 50 ms 1740 KB Output is correct
13 Correct 219 ms 6840 KB Output is correct
14 Correct 51 ms 1740 KB Output is correct
15 Correct 65 ms 1844 KB Output is correct
16 Correct 273 ms 11552 KB Output is correct
17 Correct 130 ms 2332 KB Output is correct
18 Correct 52 ms 1740 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 3 ms 460 KB Output is correct
22 Correct 4 ms 460 KB Output is correct
23 Correct 3 ms 332 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 0 ms 204 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 0 ms 204 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 1 ms 204 KB Output is correct
31 Correct 1 ms 204 KB Output is correct
32 Correct 1 ms 204 KB Output is correct
33 Correct 0 ms 204 KB Output is correct