Submission #483601

# Submission time Handle Problem Language Result Execution time Memory
483601 2021-10-31T04:31:20 Z starplat Slagalica (COCI19_slagalica2) C++14
35 / 70
32 ms 3276 KB
#include <bits/stdc++.h>
#define xoxo {cout<<-1<<endl;return 0;}
using namespace std;
int n,id,x;
char l,r;
deque<int> q;
vector<int> a[10];
int max(int x,int y)
{
	return (a[x].size()>a[y].size()?a[x].size():a[y].size());
}
int main()
{
	cin.tie(0)->sync_with_stdio(0);
	cin>>n;
	for (int i=0;i<n;i++){
		cin>>id>>x;
		a[id].push_back(x);
	}
	for (int i=1;i<=8;i++) sort(a[i].begin(),a[i].end());
	for (int i=1;i<=8;i++) reverse(a[i].begin(),a[i].end());
	if (max(5,6)>1||max(5,6)==0||max(7,8)>1||max(7,8)==0) xoxo
	if (a[5].size()^a[6].size()==0||a[7].size()^a[8].size()==0) xoxo
	l=(a[5].size()?'>':'<');
	r=(a[7].size()?'<':'>');
	n-=2;
	q.push_back(a[5].size()?a[5].back():a[6].back());
	while (n){
		int x=q.size();
		if (l=='>'){
			/*if (a[3].size()&&a[4].size()){
				if (a[3].back()<=a[4].back()) q.push_back(a[3].back()),a[3].pop_back(),l='>',n--;
				else q.push_back(a[4].back()),a[4].pop_back(),l='<',n--;
			}
			else*/ if (a[3].size()) q.push_back(a[3].back()),a[3].pop_back(),l='>',n--;
			else if (a[4].size()) q.push_back(a[4].back()),a[4].pop_back(),l='<',n--;
		}
		else {
		/*	if (a[2].size()&&a[1].size()){
				if (a[2].back()<=a[1].back()) q.push_back(a[2].back()),a[2].pop_back(),l='<',n--;
				else q.push_back(a[1].back()),a[1].pop_back(),l='>',n--;
			}
			else*/ if (a[2].size()) q.push_back(a[2].back()),a[2].pop_back(),l='<',n--;
			else if (a[1].size()) q.push_back(a[1].back()),a[1].pop_back(),l='>',n--;
		}
		if (x==q.size()) xoxo
	}
	if (l!=r||n) xoxo
	while (!q.empty()) cout<<q.front()<<" ",q.pop_front();
	cout<<(a[7].size()?a[7].back():a[8].back())<<endl;
}

Compilation message

slagalica.cpp: In function 'int main()':
slagalica.cpp:23:29: warning: suggest parentheses around comparison in operand of '^' [-Wparentheses]
   23 |  if (a[5].size()^a[6].size()==0||a[7].size()^a[8].size()==0) xoxo
      |                  ~~~~~~~~~~~^~~
slagalica.cpp:23:57: warning: suggest parentheses around comparison in operand of '^' [-Wparentheses]
   23 |  if (a[5].size()^a[6].size()==0||a[7].size()^a[8].size()==0) xoxo
      |                                              ~~~~~~~~~~~^~~
slagalica.cpp:46:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::deque<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |   if (x==q.size()) xoxo
      |       ~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 320 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 32 ms 2752 KB Output is correct
2 Correct 21 ms 2096 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 26 ms 2704 KB Output is correct
2 Correct 18 ms 1992 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 21 ms 1992 KB Output is correct
2 Correct 28 ms 2876 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 17 ms 1784 KB Output is correct
2 Correct 26 ms 2704 KB Output is correct
3 Correct 30 ms 3184 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 26 ms 2756 KB Output is correct
2 Correct 20 ms 1872 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 31 ms 2772 KB Output is correct
2 Correct 20 ms 1932 KB Output is correct
3 Correct 30 ms 3068 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 18 ms 2008 KB Output is correct
2 Incorrect 31 ms 2808 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 29 ms 3276 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 24 ms 2684 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 29 ms 3176 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 25 ms 2752 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 26 ms 2712 KB Output isn't correct
2 Halted 0 ms 0 KB -