Submission #534119

# Submission time Handle Problem Language Result Execution time Memory
534119 2022-03-08T01:20:09 Z Fasho Kutije (COCI21_kutije) C++14
70 / 70
797 ms 9404 KB
#include <bits/stdc++.h>
#define N 200005
#define ll long long int
#define fo(i,x,y)	for(int i=x;i<=y;i++)
#define fs(ar,n) fo(i,1,n) cin>>ar[i]
#define sp " "
#define fast cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define ii pair<int,int>
#define lli pair<ll,ll>
#define fast2 freopen ("in.txt","r",stdin);freopen ("out.txt","w",stdout);
#define mod 1000000007
using namespace std;
 
ll n,m,ar[N],sum,t,dad[N],q;
 
int find(int x)
{
    if(dad[x]==x)
        return x;
    return dad[x]=find(dad[x]);
}
void unite(int x,int y)
{
    dad[find(x)]=find(y);

}
 
int main()
{
	fast;
    cin>>n>>m>>q;
    fo(i,1,n)
        dad[i]=i;
    for(int i=1;i<=m;i++)
    {
        for(int j=1;j<=n;j++)
        {
            int a;
            cin>>a;
            unite(j,a);
        }
    }
    for(int i=1;i<=q;i++)
    {
        int a,b;
        cin>>a>>b;
        if(find(a)==find(b))
            cout<<"DA"<<endl;
        else
            cout<<"NE"<<endl;
        //cout<<find(a)<<sp<<find(b)<<endl;
    }
}
# Verdict Execution time Memory Grader output
1 Correct 633 ms 5604 KB Output is correct
2 Correct 568 ms 4932 KB Output is correct
3 Correct 541 ms 4676 KB Output is correct
4 Correct 660 ms 5644 KB Output is correct
5 Correct 657 ms 5572 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 2 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 2 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 2 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 2 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 2 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 2 ms 332 KB Output is correct
11 Correct 1 ms 328 KB Output is correct
12 Correct 2 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 633 ms 5604 KB Output is correct
2 Correct 568 ms 4932 KB Output is correct
3 Correct 541 ms 4676 KB Output is correct
4 Correct 660 ms 5644 KB Output is correct
5 Correct 657 ms 5572 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 2 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 2 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 2 ms 332 KB Output is correct
16 Correct 1 ms 328 KB Output is correct
17 Correct 2 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 732 ms 9356 KB Output is correct
27 Correct 797 ms 9404 KB Output is correct
28 Correct 598 ms 7884 KB Output is correct
29 Correct 694 ms 9132 KB Output is correct
30 Correct 605 ms 8016 KB Output is correct
31 Correct 588 ms 7984 KB Output is correct
32 Correct 795 ms 9388 KB Output is correct
33 Correct 736 ms 9392 KB Output is correct
34 Correct 754 ms 9392 KB Output is correct
35 Correct 751 ms 9388 KB Output is correct