Submission #120543

#TimeUsernameProblemLanguageResultExecution timeMemory
120543cveleKocka (COCI18_kocka)C++14
0 / 70
699 ms34204 KiB
#include <iostream> #include <sstream> #include <cstdio> #include <cstdlib> #include <cmath> #include <cctype> #include <cstring> #include <iomanip> #include <bitset> #include <algorithm> #include <vector> #include <stack> #include <queue> #include <deque> #include <set> #include <list> #include <map> using namespace std; typedef pair <int, int> ii; struct cmp1 { bool operator()(const ii &a, const ii &b) { if (a.first != b.first) { return a.first < b.first; } return a.second < b.second; } }; struct cmp2 { bool operator()(const ii &a, const ii &b) { if (a.second != b.second) { return a.second < b.second; } return a.first < b.first; } }; int n; bool ok = 1; set <ii, cmp1> row; set <ii, cmp2> col; int main() { cin >> n; for (int i = 1; i <= n; i++) { int x; cin >> x; if (x != -1) { row.insert({i, x + 1}); col.insert({i, x + 1}); } } for (int i = 1; i <= n; i++) { int x; cin >> x; if (x == -1) { auto it = row.upper_bound({i, -1}); if (it != row.end() && it->first == i) { ok = 0; } continue; } x = n - x; auto it = row.upper_bound({i, x}); if (it != row.end() && it->first == i) { ok = 0; } row.insert({i, x}); col.insert({i, x}); } for (int i = 1; i <= n; i++) { int x; cin >> x; if (x == -1) { auto it = col.upper_bound({-1, i}); if (it != col.end() && it->second == i) { ok = 0; } continue; } x++; auto it = col.upper_bound({x, i}); if (it != col.end() && it->second == i) { ok = 0; } row.insert({x, i}); col.insert({x, i}); } for (int i = 1; i <= n; i++) { int x; cin >> x; if (x == -1) { auto it = col.upper_bound({-1, i}); if (it != col.end() && it->second == i) { ok = 0; } continue; } x = n - x; auto it = col.upper_bound({x, i}); if (it != col.end() && it->second == i) { ok = 0; } row.insert({x, i}); col.insert({x, i}); } if (ok) { cout << "DA" << endl; } else { cout << "NE" << endl; } return 0; }
#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...