Submission #255069

#TimeUsernameProblemLanguageResultExecution timeMemory
255069Vladikus004Kocka (COCI18_kocka)C++14
14 / 70
44 ms2680 KiB
#include <bits/stdc++.h> #define inf 2e9 #define all(v) v.begin(), v.end() using namespace std; typedef long long ll; typedef long double ld; typedef pair <int, int> pii; const int N = 100000 + 3; int n, l[N], r[N], u[N], d[N], us[N]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); #ifdef LOCAL freopen("input.txt", "r", stdin); #endif // LOCAL cin >> n; for (int i = 0; i < n; i++) cin >> l[i]; for (int i = 0; i < n; i++) cin >> r[i]; for (int i = 0; i < n; i++) cin >> u[i]; for (int i = 0; i < n; i++) cin >> d[i]; for (int i = 0; i < n; i++){ if (l[i] + r[i] >= n){ cout << "NE"; return 0; } } for (int i = 0; i < n; i++){ if (u[i] + d[i] >= n){ cout << "NE"; return 0; } } for (int i = 0; i < n; i++){ if ((l[i]==-1&&r[i]!=-1)||(l[i]!=-1&&r[i]==-1)|| (u[i]==-1&&d[i]!=-1)||(u[i]!=-1&&d[i]==-1)){ cout << "NE"; return 0; } } for (int i = 0; i < n; i++){ if (l[i] != -1 && u[l[i]] > i || u[l[i]] == -1){ cout << "NE"; return 0; } if (r[i] != -1 && u[n - 1 - r[i]] > i || u[n - 1 - r[i]] == -1){ cout << "NE"; return 0; } if (l[i] != -1 && !(l[u[l[i]]] <= l[i] && n - 1 - r[u[l[i]]] >= l[i])){ cout << "NE"; return 0; } if (l[i] != -1 && !(l[u[l[i]]] <= n - 1 - r[i] && n - 1 - r[u[l[i]]] >= n - 1 - r[i])){ cout << "NE"; return 0; } } cout << "DA"; }

Compilation message (stderr)

kocka.cpp: In function 'int main()':
kocka.cpp:44:24: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
         if (l[i] != -1 && u[l[i]] > i || u[l[i]] == -1){
             ~~~~~~~~~~~^~~~~~~~~~~~~~
kocka.cpp:48:24: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
         if (r[i] != -1 && u[n - 1 - r[i]] > i || u[n - 1 - r[i]] == -1){
             ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
#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...