# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
926912 | HD1 | Kocka (COCI18_kocka) | C++17 | 82 ms | 5852 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
//we all are lost trying to be someone
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0); cin.tie(0);
#define sz(x) ll(x.size())
#define all(x) x.begin(),x.end()
#define pb push_back
#define ff first
#define ss second
using namespace std;
typedef unsigned long long ll;
const ll MAX=1000000;
const int inf=1e7;
vector<int> A[5];
int n;
set<int> comodin;
bool check(){
comodin.clear();
vector<int>U=A[2];
vector<int>L=A[0];
vector<pair<int,int>> first;
for(int i=0; i<n; i++){
first.pb({L[i],i});
}
sort(all(first));
//for(auto it:first){
//cout<<'('<<it.ff<<','<<it.ss<<')'<<' ';
//}
//cout<<'\n';
int j=0;
for(int i=0; i<n; i++){
while(j<n and first[j].ff<i){
j++;
}
int primer=first[j].ss;
if(first[j].ff!=i)primer=inf;
//cout<<primer<<'\n';
if(primer==U[i]){
comodin.insert(U[i]);
continue;
}
if(primer>U[i]){
if(comodin.count(U[i]))continue;
else return false;
}
else return false;
}
return true;
}
void turnleft(){
vector<int> x=A[0];
vector<int> y=A[1];
A[0]=A[2];
reverse(all(A[0]));
A[1]=A[3];
reverse(all(A[1]));
A[2]=y;
A[3]=x;
//for(int i=0; i<4; i++){
//for(int j=0; j<n; j++){
// cout<<A[i][j]<<' ';
//}
//cout<<'\n';
//}
return;
}
bool die(){
for(int i=0; i<n; i++){
if(A[0][i]==inf and A[1][i]==inf) continue;
if(A[0][i]+A[1][i]>=n)return false;
}
for(int i=0; i<n; i++){
if(A[2][i]==inf and A[3][i]==inf) continue;
if(A[2][i]+A[3][i]>=n)return false;
}
return true;
}
void solve(){
int a;
cin>>n;
for(int i=0; i<4; i++){
for(int j=0; j<n; j++){
cin>>a;
if(a == -1) a=inf;
A[i].pb(a);
}
}
if(!die){
cout<<"NE"<<'\n';
return;
}
for(int i=0; i<4; i++){
if(!check()){
cout<<"NE"<<'\n';
return;
}
turnleft();
}
cout<<"DA"<<'\n';
return;
}
int main(){
solve();
return 0;
}
컴파일 시 표준 에러 (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... |