Submission #1074344

#TimeUsernameProblemLanguageResultExecution timeMemory
1074344FIFI_cppRonald (COCI17_ronald)C++17
120 / 120
67 ms6280 KiB
#include <iostream> #include <vector> #include <algorithm> #include <numeric> #include <cstdlib> #include <cmath> #include <queue> #include <stack> #include <deque> #include <fstream> #include <iterator> #include <set> #include <map> #include <unordered_map> #include <iomanip> #include <cctype> #include <string> #include <cassert> #include <set> #include <bitset> #include <unordered_set> using ll = int64_t; #define pb push_back #define all(a) a.begin(),a.end() #define ppi pair<pair<int,int>,int> #define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); //#define int int64_t // xcode cant include bits/stdc++.h using namespace std; //ifstream fin ("egale.in"); //ofstream fout ("egale.out"); /* /\_/\ * (= ._.) * / > \> */ // encouraging cat const int INF = 1000000007; const int mod = 1000000007; vector<int> parent; vector<int> sizes; int find_parent(int x) { if (parent[x] == x) return x; return parent[x] = find_parent(parent[x]); } void merge(int a,int b) { a = find_parent(a); b = find_parent(b); if (a == b) return; if (sizes[b] > sizes[a]) swap(a,b); parent[b] = a; sizes[a] += sizes[b]; } bool connected(int a,int b) { if (find_parent(a) == find_parent(b)) return true; return false; } int32_t main() { int n,m; cin >> n >> m; vector<vector<int>> adj(n,vector<int> (n,0)); parent.resize(n); sizes.resize(n); for (int i = 0;i < n;i++) { parent[i] = i; sizes[i] = 1; } for (int i = 0;i < m;i++) { int a,b; cin >> a >> b; a--; b--; merge(a,b); adj[a][b] = 1; adj[b][a] = 1; } set<int> diff; for (int i = 0;i < n;i++) { for (int j = 0;j < n;j++) { if (i == j) continue; if (!adj[i][j] && find_parent(i) == find_parent(j)) { cout << "NE\n"; return 0; } } diff.insert(find_parent(i)); } if (diff.size() <= 2) { cout << "DA\n"; } else { cout << "NE\n"; } return 0; }

Compilation message (stderr)

ronald.cpp:32:9: warning: "/*" within comment [-Wcomment]
   32 | /*   /\_/\
      |
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...