| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 927090 | vjudge1 | Martian DNA (BOI18_dna) | C++17 | 153 ms | 30052 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/*
no more temmy :(
*/
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3,unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
// #include<icecream.hpp>
// using namespace icecream;
#define ll long long
#define int ll
#define ld long double
#define y1 cheza
// mt19937 rng(1983413);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<class T> using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
const int N=2e5+100;
const int M=1e3+1;
const int B=317;
const int mod=1e9+7;
const int INF=1e18;
const int lg=64;
const int dx[]={1,-1,0,0};
const int dy[]={0,0,1,-1};
const double eps=1e-9;
int n,k,rr;
int a[N];
int b[N],q[N];
bool bad(){
map<int,int>cnt;
for(int i=1;i<=n;i++){
cnt[a[i]]++;
}
for(int i=1;i<=rr;i++){
if(cnt[b[i]]<q[i]){
return 1;
}
}
return 0;
}
vector<int>g[N];
int cnt[N];
void test(){
cin>>n>>k>>rr;
for(int i=1;i<=n;i++){
cin>>a[i];
g[a[i]].push_back(i);
}
for(int i=0;i<=n;i++){
g[i].push_back(n+1);
}
for(int i=1;i<=rr;i++){
cin>>b[i]>>q[i];
cnt[b[i]]=q[i];
}
if(bad()){
cout<<"impossible\n";
return;
}
int ans=INF;
int r=0;
for(int i=1;i<=rr;i++){
r=max(r,g[b[i]][q[i]-1]);
}
for(int i=1;i<=n;i++){
ans=min(ans,r-i+1);
if(cnt[a[i]]){
cnt[a[i]]++;
if(cnt[a[i]]>=g[a[i]].size()){
break;
}
r=max(r,g[a[i]][cnt[a[i]]-1]);
}
}
cout<<ans<<'\n';
}
/*
*/
signed main(){
// ic.prefix("debug->| ");
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
// cout.tie(nullptr);
long long t2=1;
// cin>>t2;
for(int i=1;i<=t2;i++){
test();
}
return 0;
}컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
