답안 #314678

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
314678 2020-10-20T19:01:07 Z mohamedsobhi777 Kocka (COCI18_kocka) C++14
70 / 70
149 ms 21400 KB
#include <bits/stdc++.h>

#pragma GCC optimize("-Ofast")
//#pragma GCC optimize("trapv")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx2,tune=native")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-funroll-loops")

#define I inline void
#define S struct
#define vi vector<int>
#define vii vector<pair<int, int>>
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;
using ll = long long;
using ld = long double;

const int N = 2e5 + 7, mod = 1e9 + 7;
const ll inf = 2e18;

// How interesting!

int n;
int d[4][N];
vector<int> vec[N], hrn[N];
void no()
{
        cout << "NE";
        exit(0);
}
int main()
{
        ios_base::sync_with_stdio(0);
        cin.tie(0);
        //freopen("in.in", "r", stdin);
        cin >> n;
        for (int i = 0; i < 4; ++i)
        {
                for (int j = 0; j < n; ++j)
                {
                        cin >> d[i][j];
                }
        }
        for (int i = 0; i < n; ++i)
        {
                int a = d[0][i], b = d[1][i];
                if (min(a, b) == -1 && max(a, b) > -1)
                        no();
                if (a + b >= n)
                        no();
                if (a == -1)
                        continue;
                vec[a].push_back(i);
                hrn[i].push_back(a);
                if (a != n - 1 - b)
                {
                        hrn[i].push_back(n - 1 - b);
                        vec[n - 1 - b].push_back(i);
                }
        }

        for (int i = 0; i < n; ++i)
        {
                int a = d[2][i], b = d[3][i];
                if (min(a, b) == -1 && max(a, b) > -1)
                        no();
                if (a + b >= n)
                        no();
                if (a == -1)
                        continue;
                hrn[a].push_back(i);
                vec[i].push_back(a);
                if (a != n - 1 - b)
                {
                        hrn[n - 1 - b].push_back(i);
                        vec[i].push_back(n - 1 - b);
                }
        }
        for (int i = 0; i < n; ++i)
        {
                if (d[0][i] == -1 && hrn[i].size())
                        no();
                if (d[0][i] == -1)
                        continue;
                sort(hrn[i].begin(), hrn[i].end());
                int A = hrn[i][0];
                int B = n - hrn[i].back() - 1;
                if (d[0][i] != A || d[1][i] != B)
                        no();
        }

        for (int i = 0; i < n; ++i)
        {
                if (d[2][i] == -1 && vec[i].size())
                        no();
                if (d[2][i] == -1)
                        continue;
                sort(vec[i].begin(), vec[i].end());
                int A = vec[i][0];
                int B = n - vec[i].back() - 1;
                if (d[2][i] != A || d[3][i] != B)
                        no();
        }

        cout << "DA";
        return 0;
}

/*
        - bounds sir (segtree = 4N, eulerTour = 2N, ...)
        - a variable defined twice?
        - will overflow?
        - is it a good complexity?
        - don't mess up indices (0-indexed vs 1-indexed)
        - reset everything between testcases. 
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 9728 KB Output is correct
2 Correct 7 ms 9728 KB Output is correct
3 Correct 7 ms 9728 KB Output is correct
4 Correct 7 ms 9728 KB Output is correct
5 Correct 7 ms 9856 KB Output is correct
6 Correct 7 ms 9728 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 9760 KB Output is correct
2 Correct 8 ms 9856 KB Output is correct
3 Correct 7 ms 9728 KB Output is correct
4 Correct 8 ms 9856 KB Output is correct
5 Correct 7 ms 9728 KB Output is correct
6 Correct 7 ms 9728 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 94 ms 15736 KB Output is correct
2 Correct 44 ms 13560 KB Output is correct
3 Correct 44 ms 13560 KB Output is correct
4 Correct 38 ms 12536 KB Output is correct
5 Correct 43 ms 13632 KB Output is correct
6 Correct 43 ms 13560 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 129 ms 19320 KB Output is correct
2 Correct 38 ms 12536 KB Output is correct
3 Correct 44 ms 13660 KB Output is correct
4 Correct 77 ms 21112 KB Output is correct
5 Correct 43 ms 13816 KB Output is correct
6 Correct 149 ms 21400 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 86 ms 15736 KB Output is correct
2 Correct 37 ms 12536 KB Output is correct
3 Correct 53 ms 13560 KB Output is correct
4 Correct 42 ms 13560 KB Output is correct
5 Correct 45 ms 13560 KB Output is correct
6 Correct 37 ms 12536 KB Output is correct