Submission #1093963

# Submission time Handle Problem Language Result Execution time Memory
1093963 2024-09-28T07:06:24 Z simona1230 Joker (BOI20_joker) C++17
14 / 100
2000 ms 18776 KB
#include <bits/stdc++.h>

using namespace std;
int n,m,k;
pair<int,int> e[200001],q[200001];

void read()
{
    cin>>n>>m>>k;
    for(int i=1;i<=m;i++)
    {
        int x,y;
        cin>>x>>y;
        e[i]={x,y};
    }

    for(int i=1;i<=k;i++)
    {
        int l,r;
        cin>>l>>r;
        q[i]={l,r};
    }
}

int used[200001];
vector<int> v[200001];
bool pos;

void dfs(int i)
{
    for(int j=0;j<v[i].size();j++)
    {
        int nb=v[i][j];
        if(!used[nb])
        {
            used[nb]=1;
            if(used[i]==1)used[nb]=2;

            dfs(nb);
        }
        else if(used[i]==used[nb])pos=0;
    }
}

void slow()
{
    for(int i=1;i<=k;i++)
    {
        pos=1;
        for(int j=1;j<=n;j++)
        {
            used[j]=0;
            v[j].clear();
        }

        for(int j=1;j<q[i].first;j++)
        {
            v[e[j].first].push_back(e[j].second);
            v[e[j].second].push_back(e[j].first);
        }

        for(int j=q[i].second+1;j<=m;j++)
        {
            v[e[j].first].push_back(e[j].second);
            v[e[j].second].push_back(e[j].first);
        }

        for(int j=1;j<=n;j++)
        {
            if(!used[j])
            {
                used[j]=1;
                dfs(j);
            }
        }

        if(pos)cout<<"NO"<<endl;
        else cout<<"YES"<<endl;
    }
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	read();
	slow();
	return 0;
}

Compilation message

Joker.cpp: In function 'void dfs(int)':
Joker.cpp:31:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |     for(int j=0;j<v[i].size();j++)
      |                 ~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4952 KB Output is correct
2 Correct 2 ms 4956 KB Output is correct
3 Correct 3 ms 4956 KB Output is correct
4 Correct 2 ms 4956 KB Output is correct
5 Correct 2 ms 4956 KB Output is correct
6 Correct 2 ms 4956 KB Output is correct
7 Correct 2 ms 4956 KB Output is correct
8 Correct 3 ms 4956 KB Output is correct
9 Correct 3 ms 4956 KB Output is correct
10 Correct 2 ms 5164 KB Output is correct
11 Correct 3 ms 4956 KB Output is correct
12 Correct 3 ms 4956 KB Output is correct
13 Correct 3 ms 4956 KB Output is correct
14 Correct 3 ms 4956 KB Output is correct
15 Correct 3 ms 4956 KB Output is correct
16 Correct 2 ms 4956 KB Output is correct
17 Correct 3 ms 4952 KB Output is correct
18 Correct 3 ms 4956 KB Output is correct
19 Correct 3 ms 5160 KB Output is correct
20 Correct 2 ms 4956 KB Output is correct
21 Correct 3 ms 4956 KB Output is correct
22 Correct 3 ms 4956 KB Output is correct
23 Correct 3 ms 5212 KB Output is correct
24 Correct 3 ms 4956 KB Output is correct
25 Correct 2 ms 5168 KB Output is correct
26 Correct 3 ms 4956 KB Output is correct
27 Correct 2 ms 5184 KB Output is correct
28 Correct 3 ms 4956 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4952 KB Output is correct
2 Correct 2 ms 4956 KB Output is correct
3 Correct 3 ms 4956 KB Output is correct
4 Correct 2 ms 4956 KB Output is correct
5 Correct 2 ms 4956 KB Output is correct
6 Correct 2 ms 4956 KB Output is correct
7 Correct 2 ms 4956 KB Output is correct
8 Correct 3 ms 4956 KB Output is correct
9 Correct 3 ms 4956 KB Output is correct
10 Correct 2 ms 5164 KB Output is correct
11 Correct 3 ms 4956 KB Output is correct
12 Correct 3 ms 4956 KB Output is correct
13 Correct 3 ms 4956 KB Output is correct
14 Correct 3 ms 4956 KB Output is correct
15 Correct 3 ms 4956 KB Output is correct
16 Correct 2 ms 4956 KB Output is correct
17 Correct 3 ms 4952 KB Output is correct
18 Correct 3 ms 4956 KB Output is correct
19 Correct 3 ms 5160 KB Output is correct
20 Correct 2 ms 4956 KB Output is correct
21 Correct 3 ms 4956 KB Output is correct
22 Correct 3 ms 4956 KB Output is correct
23 Correct 3 ms 5212 KB Output is correct
24 Correct 3 ms 4956 KB Output is correct
25 Correct 2 ms 5168 KB Output is correct
26 Correct 3 ms 4956 KB Output is correct
27 Correct 2 ms 5184 KB Output is correct
28 Correct 3 ms 4956 KB Output is correct
29 Correct 44 ms 5212 KB Output is correct
30 Correct 85 ms 5296 KB Output is correct
31 Correct 86 ms 5208 KB Output is correct
32 Correct 71 ms 5300 KB Output is correct
33 Correct 59 ms 5212 KB Output is correct
34 Correct 93 ms 5212 KB Output is correct
35 Correct 93 ms 5212 KB Output is correct
36 Correct 42 ms 5208 KB Output is correct
37 Correct 65 ms 5208 KB Output is correct
38 Correct 59 ms 5212 KB Output is correct
39 Correct 64 ms 5212 KB Output is correct
40 Correct 67 ms 5208 KB Output is correct
41 Correct 67 ms 5212 KB Output is correct
42 Correct 65 ms 5208 KB Output is correct
43 Correct 56 ms 5208 KB Output is correct
44 Correct 72 ms 5212 KB Output is correct
45 Correct 78 ms 5212 KB Output is correct
46 Correct 84 ms 5212 KB Output is correct
47 Correct 63 ms 5212 KB Output is correct
48 Correct 68 ms 5296 KB Output is correct
49 Correct 77 ms 5212 KB Output is correct
50 Correct 85 ms 5212 KB Output is correct
51 Correct 64 ms 5208 KB Output is correct
52 Correct 74 ms 5208 KB Output is correct
53 Correct 80 ms 5208 KB Output is correct
54 Correct 93 ms 5312 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4952 KB Output is correct
2 Correct 2 ms 4956 KB Output is correct
3 Execution timed out 2057 ms 18776 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4952 KB Output is correct
2 Correct 2 ms 4956 KB Output is correct
3 Correct 3 ms 4956 KB Output is correct
4 Correct 2 ms 4956 KB Output is correct
5 Correct 2 ms 4956 KB Output is correct
6 Correct 2 ms 4956 KB Output is correct
7 Correct 2 ms 4956 KB Output is correct
8 Correct 3 ms 4956 KB Output is correct
9 Correct 3 ms 4956 KB Output is correct
10 Correct 2 ms 5164 KB Output is correct
11 Correct 3 ms 4956 KB Output is correct
12 Correct 3 ms 4956 KB Output is correct
13 Correct 3 ms 4956 KB Output is correct
14 Correct 3 ms 4956 KB Output is correct
15 Correct 3 ms 4956 KB Output is correct
16 Correct 2 ms 4956 KB Output is correct
17 Correct 3 ms 4952 KB Output is correct
18 Correct 3 ms 4956 KB Output is correct
19 Correct 3 ms 5160 KB Output is correct
20 Correct 2 ms 4956 KB Output is correct
21 Correct 3 ms 4956 KB Output is correct
22 Correct 3 ms 4956 KB Output is correct
23 Correct 3 ms 5212 KB Output is correct
24 Correct 3 ms 4956 KB Output is correct
25 Correct 2 ms 5168 KB Output is correct
26 Correct 3 ms 4956 KB Output is correct
27 Correct 2 ms 5184 KB Output is correct
28 Correct 3 ms 4956 KB Output is correct
29 Execution timed out 2057 ms 18776 KB Time limit exceeded
30 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4952 KB Output is correct
2 Correct 2 ms 4956 KB Output is correct
3 Correct 3 ms 4956 KB Output is correct
4 Correct 2 ms 4956 KB Output is correct
5 Correct 2 ms 4956 KB Output is correct
6 Correct 2 ms 4956 KB Output is correct
7 Correct 2 ms 4956 KB Output is correct
8 Correct 3 ms 4956 KB Output is correct
9 Correct 3 ms 4956 KB Output is correct
10 Correct 2 ms 5164 KB Output is correct
11 Correct 3 ms 4956 KB Output is correct
12 Correct 3 ms 4956 KB Output is correct
13 Correct 3 ms 4956 KB Output is correct
14 Correct 3 ms 4956 KB Output is correct
15 Correct 3 ms 4956 KB Output is correct
16 Correct 2 ms 4956 KB Output is correct
17 Correct 3 ms 4952 KB Output is correct
18 Correct 3 ms 4956 KB Output is correct
19 Correct 3 ms 5160 KB Output is correct
20 Correct 2 ms 4956 KB Output is correct
21 Correct 3 ms 4956 KB Output is correct
22 Correct 3 ms 4956 KB Output is correct
23 Correct 3 ms 5212 KB Output is correct
24 Correct 3 ms 4956 KB Output is correct
25 Correct 2 ms 5168 KB Output is correct
26 Correct 3 ms 4956 KB Output is correct
27 Correct 2 ms 5184 KB Output is correct
28 Correct 3 ms 4956 KB Output is correct
29 Correct 44 ms 5212 KB Output is correct
30 Correct 85 ms 5296 KB Output is correct
31 Correct 86 ms 5208 KB Output is correct
32 Correct 71 ms 5300 KB Output is correct
33 Correct 59 ms 5212 KB Output is correct
34 Correct 93 ms 5212 KB Output is correct
35 Correct 93 ms 5212 KB Output is correct
36 Correct 42 ms 5208 KB Output is correct
37 Correct 65 ms 5208 KB Output is correct
38 Correct 59 ms 5212 KB Output is correct
39 Correct 64 ms 5212 KB Output is correct
40 Correct 67 ms 5208 KB Output is correct
41 Correct 67 ms 5212 KB Output is correct
42 Correct 65 ms 5208 KB Output is correct
43 Correct 56 ms 5208 KB Output is correct
44 Correct 72 ms 5212 KB Output is correct
45 Correct 78 ms 5212 KB Output is correct
46 Correct 84 ms 5212 KB Output is correct
47 Correct 63 ms 5212 KB Output is correct
48 Correct 68 ms 5296 KB Output is correct
49 Correct 77 ms 5212 KB Output is correct
50 Correct 85 ms 5212 KB Output is correct
51 Correct 64 ms 5208 KB Output is correct
52 Correct 74 ms 5208 KB Output is correct
53 Correct 80 ms 5208 KB Output is correct
54 Correct 93 ms 5312 KB Output is correct
55 Execution timed out 2036 ms 16720 KB Time limit exceeded
56 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4952 KB Output is correct
2 Correct 2 ms 4956 KB Output is correct
3 Correct 3 ms 4956 KB Output is correct
4 Correct 2 ms 4956 KB Output is correct
5 Correct 2 ms 4956 KB Output is correct
6 Correct 2 ms 4956 KB Output is correct
7 Correct 2 ms 4956 KB Output is correct
8 Correct 3 ms 4956 KB Output is correct
9 Correct 3 ms 4956 KB Output is correct
10 Correct 2 ms 5164 KB Output is correct
11 Correct 3 ms 4956 KB Output is correct
12 Correct 3 ms 4956 KB Output is correct
13 Correct 3 ms 4956 KB Output is correct
14 Correct 3 ms 4956 KB Output is correct
15 Correct 3 ms 4956 KB Output is correct
16 Correct 2 ms 4956 KB Output is correct
17 Correct 3 ms 4952 KB Output is correct
18 Correct 3 ms 4956 KB Output is correct
19 Correct 3 ms 5160 KB Output is correct
20 Correct 2 ms 4956 KB Output is correct
21 Correct 3 ms 4956 KB Output is correct
22 Correct 3 ms 4956 KB Output is correct
23 Correct 3 ms 5212 KB Output is correct
24 Correct 3 ms 4956 KB Output is correct
25 Correct 2 ms 5168 KB Output is correct
26 Correct 3 ms 4956 KB Output is correct
27 Correct 2 ms 5184 KB Output is correct
28 Correct 3 ms 4956 KB Output is correct
29 Correct 44 ms 5212 KB Output is correct
30 Correct 85 ms 5296 KB Output is correct
31 Correct 86 ms 5208 KB Output is correct
32 Correct 71 ms 5300 KB Output is correct
33 Correct 59 ms 5212 KB Output is correct
34 Correct 93 ms 5212 KB Output is correct
35 Correct 93 ms 5212 KB Output is correct
36 Correct 42 ms 5208 KB Output is correct
37 Correct 65 ms 5208 KB Output is correct
38 Correct 59 ms 5212 KB Output is correct
39 Correct 64 ms 5212 KB Output is correct
40 Correct 67 ms 5208 KB Output is correct
41 Correct 67 ms 5212 KB Output is correct
42 Correct 65 ms 5208 KB Output is correct
43 Correct 56 ms 5208 KB Output is correct
44 Correct 72 ms 5212 KB Output is correct
45 Correct 78 ms 5212 KB Output is correct
46 Correct 84 ms 5212 KB Output is correct
47 Correct 63 ms 5212 KB Output is correct
48 Correct 68 ms 5296 KB Output is correct
49 Correct 77 ms 5212 KB Output is correct
50 Correct 85 ms 5212 KB Output is correct
51 Correct 64 ms 5208 KB Output is correct
52 Correct 74 ms 5208 KB Output is correct
53 Correct 80 ms 5208 KB Output is correct
54 Correct 93 ms 5312 KB Output is correct
55 Execution timed out 2057 ms 18776 KB Time limit exceeded
56 Halted 0 ms 0 KB -