Submission #386686

#TimeUsernameProblemLanguageResultExecution timeMemory
386686KeshiScales (IOI15_scales)C++17
0 / 100
2 ms492 KiB
//In the name of God
#include <bits/stdc++.h>
#include "scales.h"
using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;

const ll maxn = 2e5 + 100;
const ll mod = 1e9 + 7;
const ll inf = 1e18;

#define fast_io ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_io freopen("input.txt", "r+", stdin);freopen("output.txt", "w+", stdout);
#define pb push_back
#define Mp make_pair
#define F first
#define S second
#define Sz(x) ll((x).size())
#define all(x) (x).begin(), (x).end()
#define g1 getLightest
#define g2 getMedian
#define g3 getHeaviest
#define g4 getNextLightest

int t = 0, t2;

void init(int T) {
	t = T;
	t2 = T;
    srand(time(NULL));
}

int a[] = {1, 2, 3, 4, 5, 6};
int b[] = {1, 2, 3, 4, 5, 6};

void Do(ll i, ll j){
	b[i] = a[i];
	for(ll o = i; o > j; o--){
		swap(b[o], b[o - 1]);
	}
}

ll cnt = 0;

void orderCoins(){
	//random_shuffle(a, a + 6);
	cnt += 3;
	b[0] = g1(a[0], a[1], a[2]);
	b[1] = g2(a[0], a[1], a[2]);
	b[2] = g3(a[0], a[1], a[2]);
	// solve b[3]
	cnt++;
	ll x = g4(b[0], b[1], b[2], a[3]);
	if(x == b[0]){
		cnt++;
		if(g1(b[0], b[1], a[3]) == a[3]) Do(3, 0);
		else Do(3, 3);
	}
	else{
		if(x == b[1]) Do(3, 1);
		else Do(3, 2);
	}
	// solve b[4]
	x = g4(b[0], b[1], b[2], a[4]);
	cnt++;
	if(x != b[0]){
		if(x == b[1]) Do(4, 1);
		else Do(4, 2);
	}
	else{
		cnt++;
		x = g4(b[0], b[1], b[3], a[4]);
		if(x == b[3]) Do(4, 3);
		else{
			cnt++;
			if(g1(b[0], b[1], a[4]) == a[4]) Do(4, 0);
			else Do(4, 4);
		}
	}
	// solve b[5]
	cnt++;
	x = g4(b[0], b[1], b[2], a[5]);
	if(x != b[0]){
		if(x == b[1]) Do(5, 1);
		else Do(5, 2);
	}
	else{
		cnt++;
		x = g4(b[0], b[3], b[4], a[5]);
		if(x != b[0]){
			if(x == b[3]) Do(5, 3);
			else Do(5, 4);
		}
		else{
			cnt++;
			if(g1(b[0], b[1], a[5]) == a[5]) Do(5, 0);
			else Do(5, 5);
		}
	}
	t--;
	if(t == 0){
		long double r = 1.0 * cnt / t2;
		if(r > 9) cout << 1 /0;
	}
    answer(b);
}

/*int main(){
    fast_io;



    return 0;
}
*/

Compilation message (stderr)

scales.cpp: In function 'void init(int)':
scales.cpp:31:15: warning: conversion from 'time_t' {aka 'long int'} to 'unsigned int' may change value [-Wconversion]
   31 |     srand(time(NULL));
      |           ~~~~^~~~~~
scales.cpp: In function 'void orderCoins()':
scales.cpp:103:25: warning: conversion from 'll' {aka 'long long int'} to 'double' may change value [-Wconversion]
  103 |   long double r = 1.0 * cnt / t2;
      |                         ^~~
scales.cpp:104:23: warning: division by zero [-Wdiv-by-zero]
  104 |   if(r > 9) cout << 1 /0;
      |                     ~~^~
#Verdict Execution timeMemoryGrader output
Fetching results...