Submission #1017580

#TimeUsernameProblemLanguageResultExecution timeMemory
1017580AmirAli_H1Scales (IOI15_scales)C++17
45.45 / 100
1 ms416 KiB
// In the name of Allah

#include <bits/stdc++.h>
#include "scales.h"
using namespace std;

typedef		long long int			ll;
typedef		long double				ld;
typedef		pair<int, int>			pii;
typedef		pair<ll, ll>			pll;
typedef		complex<ld>				cld;

#define		all(x)					(x).begin(),(x).end()
#define		len(x)					((ll) (x).size())
#define		F						first
#define		S						second
#define		pb						push_back
#define		sep						' '
#define		endl					'\n'
#define		Mp						make_pair
#define		kill(x)					cout << x << '\n', exit(0)
#define		set_dec(x)				cout << fixed << setprecision(x);
#define		file_io(x,y)			freopen(x, "r", stdin); freopen(y, "w", stdout);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int mark[7];
vector<int> res, vc;
vector<int> adjr[7];

void init(int T) {
    return ;
}

void opr() {
	int j = len(vc);
	int r = getLightest(vc[j - 1], vc[j - 2], vc[j - 3]);
	for (int x : {vc[j - 1], vc[j - 2], vc[j - 3]}) {
		if (x != r) adjr[x].pb(r);
	}
	vc.pop_back(); vc.pop_back(); vc.pop_back();
	vc.pb(r);
}

int get_min() {
	vc.clear();
	for (int i = 1; i <= 6; i++) {
		if (!mark[i]) {
			bool ok = 1;
			for (int j : adjr[i]) {
				if (!mark[j]) {
					ok = 0;
					break;
				}
			}
			if (ok) vc.pb(i);
		}
	}
	while (len(vc) >= 3) {
		opr();
	}
	if (len(vc) == 2) {
		for (int i = 1; i <= 6; i++) {
			if (!mark[i]) {
				if (i != vc[0] && i != vc[1]) {
					vc.pb(i);
					break;
				}
			}
		}
		opr();
	}
	
	return vc[0];
}

void orderCoins() {
	fill(mark, mark + 7, 0); res.clear();
	for (int i = 1; i <= 6; i++) adjr[i].clear();
	
    for (int i = 0; i < 3; i++) {
    	int x = get_min();
    	mark[x] = 1; res.pb(x);
	}
	
	while (len(res) < 5) {
		int x = res.back();
		
		vc.clear();
		for (int i = 1; i <= 6; i++) {
			if (!mark[i]) vc.pb(i);
		}
		for (int i = 1; i <= 6; i++) {
			if (len(vc) >= 3) break;
			if (mark[i] && i != x) vc.pb(i);
		}
		
		int r = getNextLightest(vc[0], vc[1], vc[2], x);
		mark[r] = 1; res.pb(r);
	}
	for (int i = 1; i <= 6; i++) {
		if (!mark[i]) {
			mark[i] = 1; res.pb(i);
		}
	}
    
    int W[6];
    for (int i = 0; i < 6; i++) W[i] = res[i];
    answer(W);
}

Compilation message (stderr)

scales.cpp: In function 'void init(int)':
scales.cpp:30:15: warning: unused parameter 'T' [-Wunused-parameter]
   30 | void init(int T) {
      |           ~~~~^
scales.cpp: In function 'void opr()':
scales.cpp:14:22: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   14 | #define  len(x)     ((ll) (x).size())
      |                     ~^~~~~~~~~~~~~~~~
scales.cpp:35:10: note: in expansion of macro 'len'
   35 |  int j = len(vc);
      |          ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...