# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
472274 | elgamalsalman | Political Development (BOI17_politicaldevelopment) | C++14 | 67 ms | 4516 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
typedef long long ll;
typedef pair<ll, ll> ii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;
int n, k;
bool foundTriple = 0, foundDouble = 0;
vvi adj;
bitset<5005> adjMatrix[5005];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n >> k;
adj.assign(n + 20, vi());
for (int i = 0; i < n; i++) {
int d; cin >> d;
while (d--) {
foundDouble = 1;
int v; cin >> v;
adj[i].push_back(v);
adj[v].push_back(i);
adjMatrix[i][v] = 1;
adjMatrix[v][i] = 1;
}
}
for (int i = 0; !foundTriple && i < n; i++) {
for (int j = 0; !foundTriple && j < adj[i].size(); j++) {
for (int k = j + 1; !foundTriple && k < adj[i].size(); k++) {
int jj = adj[i][j];
int kk = adj[i][k];
if (adjMatrix[jj][kk]) {
foundTriple = 1;
//cerr << "// " << i << ", " << jj << ", " << kk << "\n";
}
}
}
}
if (foundTriple) cout << "3\n";
else if (foundDouble) cout << "2\n";
else cout << "1\n";
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |