Submission #87301

#TimeUsernameProblemLanguageResultExecution timeMemory
87301minhtri5302Kocka (COCI18_kocka)C++14
0 / 70
4 ms620 KiB
//Trương Minh Trí #include <bits/stdc++.h> #define FOR(i, x, y) for(int i = x; i <= y; ++i) #define FORN(i, x, y) for(int i = x; i >= y; --i) #define Task "Kocka" #define maxn 10000 #define maxm #define emlacongchuacuaanh 1302 #define pii pair <int, int> #define pll pair <long long, long long> #define pb push_back #define mp make_pair #define F first #define S second #define reset(x) memset(x, 0, sizeof(x)); using namespace std; int n; int L[maxn], R[maxn], U[maxn], D[maxn]; int a[maxn][maxn]; int main() { ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); freopen(Task".inp", "r", stdin); //freopen(Task".out", "w", stdout); cin >> n; FOR(i, 1, n) cin >> L[i]; FOR(i, 1, n) cin >> R[i]; FOR(i, 1, n) cin >> U[i]; FOR(i, 1, n) cin >> D[i]; FOR(i, 1, n) { if(L[i] == 0) { if(a[i][1]==2) continue; if(a[i][1] == 1) return cout <<"NE", 0; else { a[i][1] = 2; continue; } } if(L[i] == -1) { FOR(j, 1, n) if(a[i][j] == 2) return cout <<"NE", 0; else a[i][j] = 1; continue; } FOR(j, 1, L[i]) if(a[i][j] == 2) return cout <<"NE", 0; else a[i][j] = 1; if(a[i][L[i]+1] == 1) return cout <<"NE", 0; else a[i][L[i]+1] = 2; } FOR(i, 1, n) { if(R[i] == 0) { if(a[i][n] == 2) continue; if(a[i][n] == 1) return cout <<"NE", 0; else { a[i][n] = 2; continue; } } if(R[i] == -1) { FORN(j, n, 1) if(a[i][j] == 2) return cout <<"NE", 0; else a[i][j] = 1; continue; } FORN(j, n, n - R[i] + 1) if(a[i][j] == 2) return cout <<"NE", 0; else a[i][j] = 1; if(a[i][n-R[i]] == 1) return cout <<"NE", 0; else a[i][n-R[i]] = 2; } FOR(i, 1, n) { if(U[i] == 0) { if(a[1][i]==2) continue; if(a[1][i] == 1) return cout <<"NE", 0; else { a[1][i] = 2; continue; } } if(U[i] == -1) { FOR(j, 1, n) if(a[j][i] == 2) return cout <<"NE", 0; else a[j][i] = 1; continue; } FOR(j, 1, U[i]) if(a[j][i] == 2) return cout <<"NE", 0; else a[j][i] = 1; if(a[U[i]+1][i] == 1) return cout <<"NE", 0; else a[U[i]+1][i] = 2; } FOR(i, 1, n) { if(D[i] == 0) { if(a[n][i]==2) continue; if(a[n][i] == 1) return cout <<"NE", 0; else { a[n][i] = 2; continue; } } if(D[i] == -1) { FORN(j, n, 1) if(a[j][i] == 2) return cout <<"NE", 0; else a[j][i] = 1; continue; } FORN(j, n, n - D[i] + 1) if(a[j][i] == 2) return cout <<"NE", 0; else a[j][i] = 1; if(a[n- D[i]][i] == 1) return cout <<"NE", 0; else a[n- D[i]][i] = 2; } cout << "DA"; } template <typename T> inline void read(T &x){char c;bool nega=0;while((!isdigit(c=getchar()))&&(c!='-'));if(c=='-'){nega=1;c=getchar();}x=c-48;while(isdigit(c=getchar())) x=x*10+c-48;if(nega) x=-x;} template <typename T> inline void writep(T x){if(x>9) writep(x/10);putchar(x%10+48);} template <typename T> inline void write(T x){if(x<0){putchar('-');x=-x;}writep(x);putchar(' ');} template <typename T> inline void writeln(T x){write(x);putchar('\n');}

Compilation message (stderr)

kocka.cpp: In function 'int main()':
kocka.cpp:23:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
     freopen(Task".inp", "r", stdin);
     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#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...