Submission #92449

#TimeUsernameProblemLanguageResultExecution timeMemory
92449ltomicKocka (COCI18_kocka)C++14
70 / 70
487 ms51236 KiB
#include <cstdio> #include <set> #include <cstdlib> using namespace std; const int MAXN = 1e5+5; set<int> s[2][MAXN]; int l[MAXN], r[MAXN], u[MAXN], d[MAXN]; int n; void no(int id) { printf("NE\n"); exit(0); } int main() { scanf("%d", &n); for (int i = 0; i < n; ++i) { scanf("%d", l+i); if (l[i] == -1) continue; s[0][i].insert(l[i]); s[1][l[i]].insert(i); } for (int i = 0; i < n; ++i) { scanf("%d", r+i); if (r[i] == -1) continue; s[0][i].insert(n-r[i]-1); s[1][n-r[i]-1].insert(i); } for (int i = 0; i < n; ++i) { scanf("%d", u+i); if (u[i] == -1) continue; s[1][i].insert(u[i]); s[0][u[i]].insert(i); } for (int i = 0; i < n; ++i) { scanf("%d", d+i); if (d[i] == -1) continue; s[0][n-d[i]-1].insert(i); s[1][i].insert(n-d[i]-1); } /* for (int i = 0; i < 2; ++i) { printf("DIR :%d\n", i); for (int j = 0; j < n; ++j) { printf("j: %d\n", j); for (int k: s[i][j]) printf("%d ", k); printf("\n"); } printf("\n"); }*/ for (int i = 0; i < n; ++i) { if (l[i] == -1) { if (s[0][i].size() > 0) no(0); } else { if (s[0][i].size() == 0 || l[i] != *s[0][i].begin()) no(1); } if (u[i] == -1) { if (s[1][i].size() > 0) no(2); } else if (s[1][i].size() == 0 || u[i] != *s[1][i].begin()) no(3); if (r[i] == -1) { if (s[0][i].size() > 0) no(4); } else if (s[0][i].size() == 0 || r[i] != n-1-*(--s[0][i].end())) no(5); if (d[i] == -1) { if (s[1][i].size() > 0) no(6); } else if (s[1][i].size() == 0 || d[i] != n-1-*(--s[1][i].end())) no(7); } printf("DA\n"); return 0; }

Compilation message (stderr)

kocka.cpp: In function 'int main()':
kocka.cpp:19:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &n);
   ~~~~~^~~~~~~~~~
kocka.cpp:21:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", l+i);
     ~~~~~^~~~~~~~~~~
kocka.cpp:27:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", r+i);
     ~~~~~^~~~~~~~~~~
kocka.cpp:33:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", u+i);
     ~~~~~^~~~~~~~~~~
kocka.cpp:39:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", d+i);
     ~~~~~^~~~~~~~~~~
#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...