Submission #1102508

#TimeUsernameProblemLanguageResultExecution timeMemory
1102508EkinOnalKutije (COCI21_kutije)C++17
70 / 70
136 ms5828 KiB
//#pragma GCC optimize("O3,unroll-loops,Ofast") //#pragma GCC target("avx2,bmi,bmi2,popcnt,lzcnt") #include <bits/stdc++.h> using namespace std; struct DSU { vector<int> e; void init(int N) { e = vector<int>(N,-1);} int get(int x) { return e[x] < 0 ? x : e[x] = get(e[x]); } bool sameSet(int a, int b) { return get(a) == get(b); } int size(int x) { return -e[get(x)]; } bool unite(int x, int y) { // union by size x = get(x), y = get(y); if (x == y) return 0; if (e[x] > e[y]) swap(x,y); e[x] += e[y]; e[y] = x; return 1; } }; DSU t; int n,m,q,a,b; int32_t main(){ ios_base::sync_with_stdio(0); cin.tie(0); scanf("%d %d %d",&n,&m,&q); t.init(n*m+2); for(int i=1;i<=m;i++){ for(int j=1;j<=n;j++){ scanf("%d",&a); t.unite(j,a); } } while(q--){ scanf("%d %d",&a,&b); if(t.sameSet(a,b)) printf("DA\n"); else printf("NE\n"); } return 0; }

Compilation message (stderr)

Main.cpp: In function 'int32_t main()':
Main.cpp:22:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |  scanf("%d %d %d",&n,&m,&q);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~
Main.cpp:27:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |    scanf("%d",&a);
      |    ~~~~~^~~~~~~~~
Main.cpp:32:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |   scanf("%d %d",&a,&b);
      |   ~~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...