Submission #28538

# Submission time Handle Problem Language Result Execution time Memory
28538 2017-07-16T07:08:44 Z not good but never sad(#1132, kriii) LR Springboard (FXCUP2_springboard) C++
0 / 1
1000 ms 2084 KB
#include "springboard.h"
#include <stdio.h>
#include <algorithm>
#include <vector>
using namespace std;

void Reorder(int N) {
	PutBall((N+1)/2);
	vector<int> cand;
	if (PutBall((N+1)/2) == -1){
		for (int i=(N+1)/2;i<=N;i++) cand.push_back(i);
	}
	else{
		for (int i=0;i<(N+1)/2;i++) cand.push_back(i);
	}

	for (int i=13;i>=0;i--) if (cand.size() > 1){
		int step = (cand.size() + 1) / 2;
		if (cand.back() != N) step = N + 1 - step;
		step %= N+1;

		int r = PutBall(step);
		vector<int> nxt = cand;
		for (int &x : nxt) x = (x + step) % (N+1);
		for (int i=0;i<cand.size();i++){
			if ((cand[i] - nxt[i]) * r < 0){
				cand.erase(cand.begin()+i);
				nxt.erase(nxt.begin()+i);
				i--;
			}
		}
		cand = nxt;
		sort(cand.begin(),cand.end());
	}

	int push = N-cand[0]+1;
	if (1 <= push && push <= N) PutBall(push);
}

Compilation message

springboard.cpp: In function 'void Reorder(int)':
springboard.cpp:24:17: warning: range-based 'for' loops only available with -std=c++11 or -std=gnu++11
   for (int &x : nxt) x = (x + step) % (N+1);
                 ^
springboard.cpp:25:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int i=0;i<cand.size();i++){
                 ^
# Verdict Execution time Memory Grader output
1 Execution timed out 1000 ms 2084 KB Execution timed out
2 Halted 0 ms 0 KB -