#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#define ull unsigned long long
#define pll pair<ll, ll>
#define mp make_pair
#define ll long long
#define pb push_back
#define deb(x) cout << #x << " = " << x << endl
#define all(x) x.begin(), x.end()
#define ld long double
const ll mod1 = (ll)1e9 + 7;
const ll mod2 = (ll)1e9 + 9;
const ll BASE = 47;
const ll inf = (ll)1e18;
const long double e = 2.718281828459;
const long double pi = 3.141592653;
const ld EPS = 1e-9;
using namespace std;
template <class T>
istream& operator>>(istream &in, vector<T> &arr) {
for (T &cnt : arr) {
in >> cnt;
}
return in;
};
void solve() {
ll n;
cin >> n;
vector<vector<bool>> g(n, vector<bool>(n));
ll m;
cin >> m;
while (m--) {
ll a, b;
cin >> a >> b;
a--;
b--;
g[a][b] = true;
g[b][a] = true;
}
vector<bool> ev(n);
for (int i = 1; i < n; i++) {
if (ev[i - 1]) {
if (g[i - 1][i]) {
ev[i] = true;
} else {
ev[i] = false;
}
} else {
if (g[i - 1][i]) {
ev[i] = false;
} else {
ev[i] = true;
}
}
}
bool good = true;
for (int i = 0; i < n; i++) {
for (int j = 0; j < i; j++) {
if (g[j][i]) {
if (ev[i] ^ ev[j]) {
good = false;
}
} else {
if (!(ev[i] ^ ev[j])) {
good = false;
}
}
}
}
if (good) {
cout << "DA";
return;
}
ev[0] = true;
for (int i = 1; i < n; i++) {
if (ev[i - 1]) {
if (g[i - 1][i]) {
ev[i] = true;
} else {
ev[i] = false;
}
} else {
if (g[i - 1][i]) {
ev[i] = false;
} else {
ev[i] = true;
}
}
}
good = true;
for (int i = 0; i < n; i++) {
for (int j = 0; j < i; j++) {
if (g[j][i]) {
if (ev[i] ^ ev[j]) {
good = false;
}
} else {
if (!(ev[i] ^ ev[j])) {
good = false;
}
}
}
}
if (good) {
cout << "DA";
return;
}
cout << "NE";
}
int main() {
#ifndef LOCAL
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
#else
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
cout.precision(30);
ll seed = time(0);
//cerr << "Seed: " << seed << "\n";
srand(seed);
solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
3 ms |
384 KB |
Output is correct |
3 |
Correct |
3 ms |
512 KB |
Output is correct |
4 |
Correct |
3 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
432 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
3 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
3 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
3 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
3 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
15 ms |
936 KB |
Output is correct |
3 |
Correct |
6 ms |
512 KB |
Output is correct |
4 |
Correct |
6 ms |
516 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
384 KB |
Output is correct |
2 |
Correct |
10 ms |
640 KB |
Output is correct |
3 |
Correct |
36 ms |
1912 KB |
Output is correct |
4 |
Correct |
47 ms |
2552 KB |
Output is correct |