| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 387544 | kimbj0709 | Martian DNA (BOI18_dna) | C++14 | 116 ms | 8192 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define int long long
int32_t main(){
int no_of_input,base_length,no_of_case;
int input1,input2;
vector<int> vect1;
cin >> no_of_input >> base_length >> no_of_case;
vector<int> minimum(base_length,0);
vector<int> countt(base_length,0);
for(int i=0;i<no_of_input;i++){
cin >> input1;
vect1.push_back(input1);
}
for(int i=0;i<no_of_case;i++){
cin >> input1 >> input2;
minimum[input1] = input2;
}
int currhas=base_length-no_of_case;
int pos1 = 0,pos2=0;
int ans = INT_MAX;
vector<int> temp(base_length,0);
for(int i=0;i<no_of_input;i++){
temp[vect1[i]]++;
}
for(int i=0;i<base_length;i++){
if(temp[i]<minimum[i]){
cout << "impossible";
return 0;
}
}
while(pos1<vect1.size()){
while(pos1<vect1.size()&&currhas<base_length){
if(countt[vect1[pos1]]==minimum[vect1[pos1]]-1){
currhas++;
}
countt[vect1[pos1]]++;
pos1++;
}
while(pos2<vect1.size()&&pos2<=pos1){
if(countt[vect1[pos2]]==minimum[vect1[pos2]]){
break;
}
if(pos1==pos2){
break;
}
countt[vect1[pos2]]--;
pos2++;
}
/*for(int i=0;i<countt.size();i++){
cout << countt[i] << " ";
}
cout << endl;
cout << pos1 << " " << pos2 << endl;*/
ans = min(ans,pos1-pos2);
if(pos1<vect1.size()){
countt[vect1[pos1]]++;
pos1++;
}
}
//cout << "-------------" << endl;
cout << ans;
}
컴파일 시 표준 에러 (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... | ||||
