Submission #828105

# Submission time Handle Problem Language Result Execution time Memory
828105 2023-08-17T04:49:35 Z exodus_ Martian DNA (BOI18_dna) C++14
16 / 100
1475 ms 15008 KB
#include<bits/stdc++.h>
#define se second
#define fi first
using namespace std;
const int nmax = 200002;
int N,K,R;
int arr[nmax];
pair<int,int> terms[nmax];
int countt[101][101][101]={0};
int hit[101]={0};
int main() {
    cin >> N >> K >> R;
    for(int i=1; i<=N; i++) {
        cin >> arr[i];
        hit[arr[i]]++;
    }
    bool impo=false;
    for(int i=1; i<=R; i++) {
        cin >> terms[i].fi >> terms[i].se;
        if(hit[terms[i].fi]<terms[i].se) impo=true;
    }
    if(impo) {
        cout << "impossible" << endl;
        return 0;
    }
    for(int i=1; i<=N; i++) {
        for(int j=i; j<=N; j++) {
            for(int k=i; k<=j; k++) {
                countt[i][j][arr[k]]++;
            }
        }
    }
    /*for(int i=1; i<=N; i++) {
        for(int j=i; j<=N; j++) {
            for(int k=1; k<=R; k++) {
                cout << "countt[" << i << "][" << j << "][" << terms[k].fi << "] = " << countt[i][j][terms[k].fi] << endl;
            }
        }
    }*/
    int shrtpath = INT_MAX;
    int k;
    int bisa;
    for(int i=1; i<=N; i++) {
        for(int j=i; j<=N; j++) {
            bisa=true;
            k=1;
            while(k<=R) {
                if(countt[i][j][terms[k].fi] < terms[k].se) {
                    bisa=false;
                    break;
                }
                k++;
            }
            if(bisa) {
                shrtpath = min(shrtpath, (j-i+1));
            }
        }
    }
    cout << shrtpath << endl;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2616 KB Output is correct
2 Correct 1 ms 2644 KB Output is correct
3 Correct 2 ms 2644 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 2 ms 2648 KB Output is correct
8 Correct 1 ms 2600 KB Output is correct
9 Correct 2 ms 2604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 1475 ms 13216 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 129 ms 13552 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 201 ms 15008 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -