Submission #820075

# Submission time Handle Problem Language Result Execution time Memory
820075 2023-08-10T18:49:34 Z MohamedAhmed04 The Collection Game (BOI21_swaps) C++14
5 / 100
10 ms 352 KB
#include <bits/stdc++.h>
#include "swaps.h"

using namespace std ;

int n ;

mt19937 rng(2004) ;

vector<int>solve()
{
	vector< vector<int> >v ;
	for(int i = 1 ; i <= n ; ++i)
		v.push_back({i}) ;
	while(v.size() > 1)
	{
		shuffle(v.begin() , v.end() , rng) ;
		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())
				{
					while(a[2] < v[a[0]].size())
						v2[a[0]/2].push_back(v[a[0]][a[2]]) , a[2]++ ;
					//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())
				{
					while(a[3] < v[a[1]].size())
						v2[a[0]/2].push_back(v[a[1]][a[3]]) , a[3]++ ;
					//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])
				// 		swap(v[a[0]][a[2]] , v[a[0]][a[2]+1]) ;
				// 	v2[idx2].push_back(v[a[0]][a[2]]) ;
				// 	a[2]++ ;
				// 	if(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])
				// 		swap(v[a[1]][a[3]] , v[a[1]][a[3]+1]) ;
				// 	v2[idx2].push_back(v[a[1]][a[3]]) ;
				// 	a[3]++ ;
				// 	if(a[3] == (int)(v[a[1]].size()) - 1)
				// 		v2[idx2].push_back(v[a[1]][a[3]]) , a[3]++ ;
				// 	++idx ;	
				// }
			}
			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:33: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]
   33 |     if(a[2] < v[a[0]].size() && a[3] < v[a[1]].size())
swaps.cpp:33: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]
   33 |     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: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]
   35 |     else if(a[2] < v[a[0]].size() && a[3] == v[a[1]].size())
swaps.cpp:37: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]
   37 |      while(a[2] < v[a[0]].size())
swaps.cpp:41: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]
   41 |     else if(a[2] == v[a[0]].size() && a[3] < v[a[1]].size())
swaps.cpp:41: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]
   41 |     else if(a[2] == v[a[0]].size() && a[3] < v[a[1]].size())
swaps.cpp:43: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]
   43 |      while(a[3] < v[a[1]].size())
swaps.cpp:53: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]
   53 |     if(a[2] < v[a[0]].size() && a[3] < v[a[1]].size())
swaps.cpp:53: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]
   53 |     if(a[2] < v[a[0]].size() && a[3] < v[a[1]].size())
swaps.cpp:59: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]
   59 |      if(a[2] == v[a[0]].size() && a[3] == (int)(v[a[1]].size()) - 1)
swaps.cpp:61: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]
   61 |      else if(a[3] == v[a[1]].size() && a[2] == (int)(v[a[0]].size()) - 1)
swaps.cpp:88: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]
   88 |     ok &= (a[2] == v[a[0]].size() && a[3] == v[a[1]].size()) ;
swaps.cpp:88: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]
   88 |     ok &= (a[2] == v[a[0]].size() && a[3] == v[a[1]].size()) ;
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Correct
2 Correct 1 ms 316 KB Correct
3 Correct 4 ms 256 KB Correct
4 Correct 6 ms 336 KB Correct
5 Correct 8 ms 336 KB Correct
6 Correct 10 ms 336 KB Correct
7 Correct 6 ms 348 KB Correct
8 Correct 10 ms 336 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Correct
2 Correct 2 ms 208 KB Correct
3 Correct 4 ms 208 KB Correct
4 Correct 10 ms 336 KB Correct
5 Correct 8 ms 336 KB Correct
6 Correct 10 ms 336 KB Correct
7 Correct 7 ms 336 KB Correct
8 Correct 8 ms 336 KB Correct
9 Runtime error 6 ms 352 KB Execution killed with signal 13
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 208 KB Not correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 208 KB Not correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 208 KB Not correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 208 KB Not correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 208 KB Not correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 208 KB Not correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 208 KB Not correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 208 KB Not correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 208 KB Not correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 208 KB Not correct
2 Halted 0 ms 0 KB -