답안 #1022697

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1022697 2024-07-14T01:58:22 Z angels Martian DNA (BOI18_dna) C++17
0 / 100
147 ms 9236 KB
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n, k, r;
    cin>>n>>k>>r;
    int a[n], b[k+1], visited[k+1];
    memset(visited, 0, sizeof(visited));
    set<int>barani;
    for(int i=0; i<k+1; i++)
        b[i]=-1;
    for(int i=0; i<n; i++)
    {
        cin>>a[i];
    }
    for(int i=0; i<r; i++)
    {
        int aa, bb;
        cin>>aa>>bb;
        b[aa]=bb;
        barani.insert(aa);
    }
    int vishok=0, manjak=barani.size(), rez=INT_MAX;
    for(int r=0, l=0; r<n; r++)
    {
        bool kiki=0;
        while(l<r && manjak==0)
        {
            if(barani.find(a[l])!=barani.end())
            {
                visited[a[l]]--;
                if(visited[a[l]]==b[a[l]]-1)
                {
                    manjak++;
                    kiki=1;
                    visited[a[l]]++;
                    l--;
                }
            }
            l++;
        }
        if(kiki)
            manjak=0;
        if(manjak==0)
        {
            rez=min(r-l, rez);
        }
        if(barani.find(a[r])!=barani.end())
        {
            visited[a[r]]++;
            if(visited[a[r]]==b[a[r]])
            {
                manjak--;
            }
            /*if(visited[a[r]]==b[a[r]]+1)
            {
                vishok++;
            }*/
        }
        if(manjak==0)
        {
            rez=min(r-l+1, rez);
        }
    }
    /*if(manjak==0)
    {
        rez=min(r-l, rez);
    }*/
    if(rez==INT_MAX)
        cout<<"impossible";
    else
        cout<<rez;

    return 0;
}

Compilation message

dna.cpp: In function 'int main()':
dna.cpp:24:9: warning: unused variable 'vishok' [-Wunused-variable]
   24 |     int vishok=0, manjak=barani.size(), rez=INT_MAX;
      |         ^~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Incorrect 0 ms 348 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 456 KB Output is correct
3 Correct 1 ms 444 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Incorrect 0 ms 348 KB Output isn't correct
13 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 19 ms 1372 KB Output is correct
2 Correct 20 ms 1372 KB Output is correct
3 Correct 22 ms 1628 KB Output is correct
4 Correct 19 ms 1628 KB Output is correct
5 Correct 39 ms 2960 KB Output is correct
6 Correct 20 ms 1372 KB Output is correct
7 Correct 23 ms 1628 KB Output is correct
8 Correct 41 ms 4040 KB Output is correct
9 Correct 34 ms 2024 KB Output is correct
10 Correct 23 ms 1372 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 600 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Incorrect 0 ms 348 KB Output isn't correct
23 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 134 ms 7252 KB Output is correct
2 Correct 114 ms 6004 KB Output is correct
3 Correct 84 ms 3696 KB Output is correct
4 Correct 19 ms 1368 KB Output is correct
5 Correct 122 ms 7812 KB Output is correct
6 Correct 147 ms 9236 KB Output is correct
7 Correct 57 ms 2640 KB Output is correct
8 Correct 76 ms 3156 KB Output is correct
9 Correct 18 ms 1368 KB Output is correct
10 Correct 20 ms 1372 KB Output is correct
11 Correct 21 ms 1624 KB Output is correct
12 Correct 21 ms 1572 KB Output is correct
13 Correct 37 ms 2900 KB Output is correct
14 Correct 20 ms 1372 KB Output is correct
15 Correct 23 ms 1628 KB Output is correct
16 Correct 45 ms 3888 KB Output is correct
17 Correct 34 ms 2140 KB Output is correct
18 Correct 22 ms 1368 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 496 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Incorrect 0 ms 432 KB Output isn't correct
31 Halted 0 ms 0 KB -