# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
726890 | kerem | Slagalica (COCI19_slagalica2) | C++14 | 67 ms | 340 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define fir first
#define sec second
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int32_t main(){
int n,k=0,l,r,a,b,c,d,i,j,sayac=1;
cin >> n;
for(int ind=0;ind<n;ind++){
int x,y;
cin >> x >> y;
if(x==5) l=1,a=y,k++;
else if(x==6) l=0,a=y,k--;
else if(x==7) r=1,d=y,k++;
else if(x==8) r=0,d=y,k--;
else if(sayac==1) i=x,b=y,sayac++;
else j=x,c=y;
if(x==1) k+=2;
if(x==4) k-=2;
}
if(k!=0){
cout << -1;
return 0;
}
cout << a << " ";
if(n==3){
if(i==2 and l==1){
cout << -1;
return 0;
}
if(i==3 and l==0){
cout << -1;
return 0;
}
cout << b << " ";
}
if(n==4){
if(i>j) {int temp=i;i=j;j=temp;temp=b;b=c;c=temp;}
if(i==1 and j==2)
cout << c << " " << b << " ";
if(i==1 and j==3)
cout << b << " " << c << " ";
if(i==1 and j==4){
if(l==0)
cout << b << " " << c << " ";
else
cout << c << " " << b << " ";
}
if(i==2 and j==2){
if(l==1){
cout << -1;
return 0;
}
cout << min(c,b) << " " << max(c,b) << " ";
}
if(i==2 and j==4)
cout << c << " " << b << " ";
if(i==3 and j==3){
if(l==0){
cout << -1;
return 0;
}
cout << min(c,b) << " " << max(c,b) << " ";
}
if(i==3 and j==4)
cout << b << " " << c << " ";
}
cout << d;
return 0;
}
Compilation message (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... |
# | 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... |
# | 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... |