# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
147239 | MatesV13 | Kocka (COCI18_kocka) | C++11 | 203 ms | 17372 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;
int n, a[5][100000], maks, mini;
vector<int> x[100005], y[100005];
int main (){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n;
for (int i=0; i<n; i++){
cin >> a[1][i];
if (a[1][i]==-1) continue;
x[i].push_back(a[1][i]);
y[a[1][i]].push_back(i);
}
for (int i=0; i<n; i++){
cin >> a[2][i];
if (a[2][i]==-1) continue;
a[2][i]= n-a[2][i]-1;
x[i].push_back(a[2][i]);
y[a[2][i]].push_back(i);
}
for (int i=0; i<n; i++){
cin >> a[3][i];
if (a[3][i]==-1) continue;
y[i].push_back(a[3][i]);
x[a[3][i]].push_back(i);
}
for (int i=0; i<n; i++){
cin >> a[4][i];
if (a[4][i]==-1) continue;
a[4][i]= n-a[4][i]-1;
y[i].push_back(a[4][i]);
x[a[4][i]].push_back(i);
}
bool ok=1;
for (int i=0;i<n;i++){
mini = 100001;
if (x[i].empty()) mini=-1;
for (int j=0; j<x[i].size();j++) mini = min (mini, x[i][j]);
if (mini!=a[1][i]) ok=0;
}
for (int i=0;i<n;i++){
maks = -1;
for (int j=0; j<x[i].size();j++) maks = max (maks, x[i][j]);
if (maks!=a[2][i]) ok=0;
}
for (int i=0;i<n;i++){
mini = 100001;
if (y[i].empty()) mini=-1;
for (int j=0; j<y[i].size();j++) mini = min (mini, y[i][j]);
if (mini!=a[3][i]) ok=0;
}
for (int i=0;i<n;i++){
maks = -1;
for (int j=0; j<y[i].size();j++) maks = max (maks, y[i][j]);
if (maks!=a[4][i]) ok=0;
}
if (ok) cout << "DA";
else cout << "NE";
return 0;
}
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... |