Submission #940840

# Submission time Handle Problem Language Result Execution time Memory
940840 2024-03-07T18:21:37 Z Doncho_Bonboncho Super Dango Maker (JOI22_dango3) C++17
0 / 100
10000 ms 604 KB
#include "dango3.h"
#include <bits/stdc++.h>
   
using namespace std;


#ifndef LOCAL
#define cerr if(false)cerr
#endif

#define out(x) #x << " = " << x << "  "

int n;

void f( int currBr, std::vector< int > v ){

	if( currBr == 1 ){
		if( v.size() != n ) while( true );
		Answer( v );
		return;
	}

	int l = 0, r = v.size();
	while( l != r-1 ){

		std::vector< int > V;
		int m = ( l + r ) >> 1;
		for( int i=0 ; i <= m ; i++ ) V.push_back( v[i] );

		if( Query( V ) < currBr/2 ) l = m;
		else r = m;
	}

	std::vector< int > firRet;
	std::vector< int > secRet;

	for( int i=0 ; i <= r ; i++ ) firRet.push_back( v[i] );
	for( int i=r+1 ; i < v.size() ; i++ ) secRet.push_back( v[i] );

	for( int i=0 ; i < firRet.size() ; i++ ){
		int currRem = firRet[i];
		std::swap( firRet[i], firRet[firRet.size() -1] );
		firRet.pop_back();

		if( Query( firRet ) != currBr/2 ){
			firRet.push_back( currRem );
			std::swap( firRet[i], firRet[firRet.size() -1] );
		}else secRet.push_back( currRem );
	}

	f( currBr /2, firRet );
	f( currBr /2 + ( currBr & 1 ), secRet );
}

void Solve(int N, int M) {
	
	n = N;

	std::vector< int > v;
	for( int i=1 ; i<=N*M ; i++ ) v.push_back( i );

	f( M, v );

}

Compilation message

dango3.cpp: In function 'void f(int, std::vector<int>)':
dango3.cpp:18:16: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   18 |   if( v.size() != n ) while( true );
      |       ~~~~~~~~~^~~~
dango3.cpp:38:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |  for( int i=r+1 ; i < v.size() ; i++ ) secRet.push_back( v[i] );
      |                   ~~^~~~~~~~~~
dango3.cpp:40:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |  for( int i=0 ; i < firRet.size() ; i++ ){
      |                 ~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Execution timed out 10050 ms 344 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 10009 ms 348 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 10017 ms 604 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 10019 ms 604 KB Time limit exceeded
2 Halted 0 ms 0 KB -