Submission #379189

#TimeUsernameProblemLanguageResultExecution timeMemory
379189Mounir곤돌라 (IOI14_gondola)C++14
20 / 100
53 ms4968 KiB
#include "gondola.h"
#include <bits/stdc++.h>
#define pb push_back
#define sz(x) (int)x.size()
#define chmax(x, v) x = max(x, v)
using namespace std;

int valid(int n, int inputSeq[]) {
	vector<int> restant;
	map<int, bool> vu;
	for (int ind = 0; ind < n; ++ind){
		if (vu[inputSeq[ind]])
			return 0;
		vu[inputSeq[ind]] = true;
		if (inputSeq[ind] <= n)
			restant.pb(ind);
	}

	for (int ind = 0; ind < sz(restant) - 1; ++ind){
		int a = restant[ind] - inputSeq[restant[ind]], b = restant[ind + 1] - inputSeq[restant[ind + 1]];
		a += n; a %= n;
		b += n; b %= n;

		if (a != b)
			return 0;
	}
	return 1;
}

//----------------------

struct Element {
	int ind, val;

	bool operator < (const Element &autre) const {
		return val < autre.val;
	}
};

int replacement(int n, int gondolaSeq[], int replacementSeq[]) {
	int maxi = 0;
	set<Element> reste;
	for (int ind = 0; ind < n; ++ind){
		chmax(maxi, gondolaSeq[ind]);
		if (gondolaSeq[ind] > n)
			reste.insert({ind, gondolaSeq[ind]});
	}

	for (int tour = n + 1; tour <= maxi; ++tour){
		int id = reste.begin()->ind;
		replacementSeq[tour - n - 1] = id;
		reste.erase(reste.begin());
		if (tour != gondolaSeq[id])
			reste.insert({id, tour});
	}
	return maxi - n;
}

//----------------------

int countReplacement(int n, int inputSeq[]){
	return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...