Submission #820000

# Submission time Handle Problem Language Result Execution time Memory
820000 2023-08-10T17:26:03 Z MohamedAhmed04 The Collection Game (BOI21_swaps) C++14
Compilation error
0 ms 0 KB
#include "grader.cpp"
#include <bits/stdc++.h>
#include "swaps.h"

using namespace std ;

int n ;

vector<int>solve()
{
	vector< vector<int> >v ;
	for(int i = 1 ; i <= n ; ++i)
		v.push_back({i}) ;
	while(v.size() > 1)
	{
		vector< vector<int> >v2 ;
		int sz = v.size() ;
		vector< array<int , 4> >state ;
		for(int i = 0 ; i < sz-1 ; i += 2)
		{
			state.push_back({i , i+1 , 0 , 0}) ;
			v2.push_back({}) ;
		}
		if((sz & 1))
			v2.push_back(v[sz-1]) ;
		bool ok = false ;
		while(!ok)
		{
			for(auto &a : state)
			{
				if(a[2] < v[a[0]].size() && a[3] < v[a[1]].size())
					schedule(v[a[0]][a[2]] , v[a[1]][a[3]]) ;
				else if(a[2] < v[a[0]].size() && a[3] == v[a[1]].size())
					schedule(v[a[0]][a[2]] , v[a[0]][a[2]+1]) ;
				else if(a[2] == v[a[0]].size() && a[3] < v[a[1]].size())
					schedule(v[a[1]][a[3]] , v[a[1]][a[3]+1]) ;
			}
			vector<int>cur = visit() ;
			int idx = 0 ;
			for(auto &a : state)
			{
				int idx2 = a[0] / 2 ;
				if(a[2] < v[a[0]].size() && a[3] < v[a[1]].size())
				{
					if(cur[idx])
						v2[idx2].push_back(v[a[0]][a[2]]) , a[2]++ ;
					else
						v2[idx2].push_back(v[a[1]][a[3]]) , a[3]++ ;
					if(a[2] == v[a[0]].size() && a[3] == (int)(v[a[1]].size()) - 1)
						v2[idx2].push_back(v[a[1]][a[3]]) , a[3]++ ;
					else if(a[3] == v[a[1]].size() && a[2] == (int)(v[a[0]].size()) - 1)
						v2[idx2].push_back(v[a[0]][a[2]]) , a[2]++ ;
					++idx ;
				}
				else if(a[2] < v[a[0]].size() && a[3] == v[a[1]].size())
				{
					if(cur[idx])
						v2[idx].push_back(v[a[0]][a[2]]) ;
					else
						v2[idx].push_back(v[a[0]][a[2]+1]) ;
					a[2]++ ;
					if(a[2] == (int)(v[a[0]].size()) - 1)
						v2[idx].push_back(v[a[0]][a[2]]) , a[2]++ ;
				}
				else if(a[2] == v[a[0]].size() && a[3] < v[a[1]].size())
				{
					if(cur[idx])
						v2[idx].push_back(v[a[1]][a[3]]) ;
					else
						v2[idx].push_back(v[a[1]][a[3]+1]) ;
					a[3]++ ;
					if(a[3] == (int)(v[a[1]].size()) - 1)
						v2[idx].push_back(v[a[1]][a[3]]) , a[3]++ ;	
				}
			}
			ok = true ;
			for(auto &a : state)
				ok &= (a[2] == v[a[0]].size() && a[3] == v[a[1]].size()) ;
		}
		v = v2 ;
	}
	return v[0] ;
}

void solve(int N, int V) 
{
	n = N ;
	answer(solve()) ;
	return ;
}

Compilation message

swaps.cpp: In function 'std::vector<int> solve()':
swaps.cpp:31:13: warning: comparison of integer expressions of different signedness: 'std::array<int, 4>::value_type' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |     if(a[2] < v[a[0]].size() && a[3] < v[a[1]].size())
swaps.cpp:31:38: warning: comparison of integer expressions of different signedness: 'std::array<int, 4>::value_type' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |     if(a[2] < v[a[0]].size() && a[3] < v[a[1]].size())
swaps.cpp:33:18: warning: comparison of integer expressions of different signedness: 'std::array<int, 4>::value_type' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |     else if(a[2] < v[a[0]].size() && a[3] == v[a[1]].size())
swaps.cpp:33:43: warning: comparison of integer expressions of different signedness: 'std::array<int, 4>::value_type' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |     else if(a[2] < v[a[0]].size() && a[3] == v[a[1]].size())
swaps.cpp:35:18: warning: comparison of integer expressions of different signedness: 'std::array<int, 4>::value_type' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |     else if(a[2] == v[a[0]].size() && a[3] < v[a[1]].size())
swaps.cpp:35:44: warning: comparison of integer expressions of different signedness: 'std::array<int, 4>::value_type' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |     else if(a[2] == v[a[0]].size() && a[3] < v[a[1]].size())
swaps.cpp:43:13: warning: comparison of integer expressions of different signedness: 'std::array<int, 4>::value_type' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |     if(a[2] < v[a[0]].size() && a[3] < v[a[1]].size())
swaps.cpp:43:38: warning: comparison of integer expressions of different signedness: 'std::array<int, 4>::value_type' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |     if(a[2] < v[a[0]].size() && a[3] < v[a[1]].size())
swaps.cpp:49:14: warning: comparison of integer expressions of different signedness: 'std::array<int, 4>::value_type' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |      if(a[2] == v[a[0]].size() && a[3] == (int)(v[a[1]].size()) - 1)
swaps.cpp:51:19: warning: comparison of integer expressions of different signedness: 'std::array<int, 4>::value_type' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |      else if(a[3] == v[a[1]].size() && a[2] == (int)(v[a[0]].size()) - 1)
swaps.cpp:55:18: warning: comparison of integer expressions of different signedness: 'std::array<int, 4>::value_type' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |     else if(a[2] < v[a[0]].size() && a[3] == v[a[1]].size())
swaps.cpp:55:43: warning: comparison of integer expressions of different signedness: 'std::array<int, 4>::value_type' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |     else if(a[2] < v[a[0]].size() && a[3] == v[a[1]].size())
swaps.cpp:65:18: warning: comparison of integer expressions of different signedness: 'std::array<int, 4>::value_type' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   65 |     else if(a[2] == v[a[0]].size() && a[3] < v[a[1]].size())
swaps.cpp:65:44: warning: comparison of integer expressions of different signedness: 'std::array<int, 4>::value_type' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   65 |     else if(a[2] == v[a[0]].size() && a[3] < v[a[1]].size())
swaps.cpp:78:17: warning: comparison of integer expressions of different signedness: 'std::array<int, 4>::value_type' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   78 |     ok &= (a[2] == v[a[0]].size() && a[3] == v[a[1]].size()) ;
swaps.cpp:78:43: warning: comparison of integer expressions of different signedness: 'std::array<int, 4>::value_type' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   78 |     ok &= (a[2] == v[a[0]].size() && a[3] == v[a[1]].size()) ;
/usr/bin/ld: /tmp/ccd5Efjc.o: in function `safely_read_int()':
grader.cpp:(.text+0x0): multiple definition of `safely_read_int()'; /tmp/cc5x6Ypb.o:swaps.cpp:(.text+0x150): first defined here
/usr/bin/ld: /tmp/ccd5Efjc.o: in function `schedule(int, int)':
grader.cpp:(.text+0x50): multiple definition of `schedule(int, int)'; /tmp/cc5x6Ypb.o:swaps.cpp:(.text+0x1a0): first defined here
/usr/bin/ld: /tmp/ccd5Efjc.o: in function `answer(std::vector<int, std::allocator<int> >)':
grader.cpp:(.text+0x140): multiple definition of `answer(std::vector<int, std::allocator<int> >)'; /tmp/cc5x6Ypb.o:swaps.cpp:(.text+0x290): first defined here
/usr/bin/ld: /tmp/ccd5Efjc.o: in function `visit()':
grader.cpp:(.text+0x1f0): multiple definition of `visit()'; /tmp/cc5x6Ypb.o:swaps.cpp:(.text+0x340): first defined here
/usr/bin/ld: /tmp/ccd5Efjc.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cc5x6Ypb.o:swaps.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status