Submission #782896

#TimeUsernameProblemLanguageResultExecution timeMemory
782896NothingXDScales (IOI15_scales)C++17
0 / 100
1 ms468 KiB
#include "scales.h"
#include <bits/stdc++.h>

using namespace std;

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

void debug_out(){cerr << endl;}

template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T){
	cerr << H << ' ';
	debug_out(T...);
}

#define debug(...) cerr << "(" << #__VA_ARGS__ << "): ", debug_out(__VA_ARGS__)
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define MP(x, y) make_pair(x, y)

vector<int> a, b, c;
int ans[6];

void init(int T) {
    // khob alan chikar konam
}

void sort(vector<int> &v){
	int x = getLightest(v[0], v[1], v[2]);
	int y = getMedian(v[0], v[1], v[2]);
	int z;
	for (int i = 0; i < 3; i++){
		if (v[i] != x && v[i] != y) z = v[i];
	}
	v.clear();
	v.push_back(x);
	v.push_back(y);
	v.push_back(z);
}

vector<int> addin2(int x, int y, int z){
	vector<int> res;
	int tmp = getMedian(x, y, z);
	if (tmp == x){
		res.push_back(z);
		res.push_back(x);
		res.push_back(y);
	}
	else if (tmp == z){
		res.push_back(x);
		res.push_back(z);
		res.push_back(y);
	}
	else{
		res.push_back(x);
		res.push_back(y);
		res.push_back(z);
	}
	return res;
}

vector<int> addin3(int x, int y, int z, int a){
	vector<int> res;
	int tmp = getHeaviest(y, z, a);
	if (tmp == a){
		res.push_back(x);
		res.push_back(y);
		res.push_back(z);
		res.push_back(a);
		return res;
	}
	tmp = getNextLightest(x, y, z, a);
	if (tmp == x) res.push_back(a);
	res.push_back(x);
	if (tmp == y) res.push_back(a);
	res.push_back(y);
	if (tmp == z) res.push_back(a);
	res.push_back(z);
	return res;
}

vector<int> addin4(vector<int> v, int x){
	vector<int> res;
	int tmp = getHeaviest(v[1], v[2], x);
	if (tmp == x){
		res.push_back(v[0]);
		res.push_back(v[1]);
		res.push_back(v[2]);
		tmp = getMedian(v[2], v[3], x);
		if (tmp == x){
			res.push_back(x);
			res.push_back(v[3]);
		}
		else{
			res.push_back(v[3]);
			res.push_back(x);
		}
	}
	else{
		res = addin2(v[0], v[1], x);
		res.push_back(v[2]);
		res.push_back(v[3]);
	}
	return res;
}

vector<int> addin5(vector<int> v, int x){
	vector<int> res;
	int tmp = getHeaviest(v[1], v[2], x);
	if (tmp == x){
		res.push_back(v[0]);
		res.push_back(v[1]);
		res.push_back(v[2]);
		vector<int> tmp2 = addin2(v[3], v[4], x);
		for (auto x: tmp2){
			res.push_back(x);
		}
	}
	else{
		res = addin2(v[0], v[1], x);
		res.push_back(v[2]);
		res.push_back(v[3]);
		res.push_back(v[4]);
	}
	return res;
}

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void orderCoins() {
	c.push_back(1);
	c.push_back(2);
	c.push_back(3);
	sort(c);
	c = addin3(c[0], c[1], c[2], 4);
	c = addin4(c, 5);
	c = addin5(c, 6);
	int ans[6];
	for (int i = 0; i < 6; i++) ans[i] = c[i];
	answer(ans);
}

Compilation message (stderr)

scales.cpp: In function 'void init(int)':
scales.cpp:29:15: warning: unused parameter 'T' [-Wunused-parameter]
   29 | void init(int T) {
      |           ~~~~^
scales.cpp: In function 'std::vector<int> addin3(int, int, int, int)':
scales.cpp:67:45: warning: declaration of 'a' shadows a global declaration [-Wshadow]
   67 | vector<int> addin3(int x, int y, int z, int a){
      |                                         ~~~~^
scales.cpp:26:13: note: shadowed declaration is here
   26 | vector<int> a, b, c;
      |             ^
scales.cpp: In function 'std::vector<int> addin5(std::vector<int>, int)':
scales.cpp:120:13: warning: declaration of 'auto x' shadows a parameter [-Wshadow]
  120 |   for (auto x: tmp2){
      |             ^
scales.cpp:112:39: note: shadowed declaration is here
  112 | vector<int> addin5(vector<int> v, int x){
      |                                   ~~~~^
scales.cpp: In function 'void orderCoins()':
scales.cpp:143:6: warning: declaration of 'ans' shadows a global declaration [-Wshadow]
  143 |  int ans[6];
      |      ^~~
scales.cpp:27:5: note: shadowed declaration is here
   27 | int ans[6];
      |     ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...