답안 #890288

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
890288 2023-12-21T00:44:52 Z pcc Kocka (COCI18_kocka) C++14
70 / 70
90 ms 16984 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define fs first
#define sc second
#define tlll tuple<ll,ll,ll>


const int mxn = 1e5+10;
vector<int> row[mxn],col[mxn];
int arr[4][mxn];

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n;
	cin>>n;
	for(int i = 0;i<4;i++)for(int j = 1;j<=n;j++)cin>>arr[i][j];
	bool flag = true;
	for(int i = 1;i<=n;i++){
		int neg = (arr[0][i] == -1?1:0)+(arr[1][i] == -1?1:0);
		if(neg&1)flag = false;
		neg = (arr[2][i] == -1?1:0)+(arr[3][i] == -1?1:0);
		if(neg&1)flag = false;
		if(arr[0][i]+arr[1][i]>=n)flag = false;
		if(arr[2][i]+arr[3][i]>=n)flag = false;
		row[i].push_back(arr[0][i]+1);
		row[i].push_back(n-arr[1][i]);
		col[arr[0][i]+1].push_back(i);
		col[n-arr[1][i]].push_back(i);

		col[i].push_back(arr[2][i]+1);
		col[i].push_back(n-arr[3][i]);
		row[arr[2][i]+1].push_back(i);
		row[n-arr[3][i]].push_back(i);
	}
	for(int i = 1;i<=n;i++){
		sort(row[i].begin(),row[i].end());
		sort(col[i].begin(),col[i].end());
	}
	for(int i = 1;i<=n;i++){
		if(row[i][0] != arr[0][i]+1)flag = false;
		if(row[i].back() != n-arr[1][i])flag = false;
		if(col[i][0] != arr[2][i]+1)flag = false;
		if(col[i].back() != n-arr[3][i])flag = false;
	}
	cout<<(flag?"DA":"NE");
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 6488 KB Output is correct
2 Correct 2 ms 6492 KB Output is correct
3 Correct 2 ms 6492 KB Output is correct
4 Correct 2 ms 6492 KB Output is correct
5 Correct 2 ms 6580 KB Output is correct
6 Correct 2 ms 6492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 6492 KB Output is correct
2 Correct 3 ms 6492 KB Output is correct
3 Correct 2 ms 6492 KB Output is correct
4 Correct 2 ms 6492 KB Output is correct
5 Correct 2 ms 6492 KB Output is correct
6 Correct 2 ms 6492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 53 ms 15812 KB Output is correct
2 Correct 68 ms 16744 KB Output is correct
3 Correct 70 ms 16976 KB Output is correct
4 Correct 34 ms 15540 KB Output is correct
5 Correct 89 ms 16976 KB Output is correct
6 Correct 64 ms 16892 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 62 ms 16908 KB Output is correct
2 Correct 34 ms 15664 KB Output is correct
3 Correct 90 ms 16980 KB Output is correct
4 Correct 41 ms 16208 KB Output is correct
5 Correct 65 ms 16808 KB Output is correct
6 Correct 57 ms 16740 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 55 ms 15768 KB Output is correct
2 Correct 35 ms 15552 KB Output is correct
3 Correct 67 ms 16932 KB Output is correct
4 Correct 71 ms 16744 KB Output is correct
5 Correct 66 ms 16984 KB Output is correct
6 Correct 34 ms 15552 KB Output is correct