Submission #1236079

#TimeUsernameProblemLanguageResultExecution timeMemory
1236079NurislamScales (IOI15_scales)C++20
Compilation error
0 ms0 KiB
//#pragma once
#include <bits/stdc++.h>

using namespace std;

int inf = 100;
int getMedian(int A, int B, int C);
int getHeaviest(int A, int B, int C);
int getLightest(int A, int B, int C);
int getNextLightest(int A, int B, int C, int D);

void answer(int C[]);

vector<vector<int>> pr;
vector<pair<int,vector<int>> > op;

void init(int T){
	
	/*
	function<int(int, vector<vector<int>>) > rec = [&](int ps, vector<vector<int>> left) {
		if(ps == 6 && left.size() == 1) return 0;
		if(ps == 6 && left.size() != 1) return inf;
		
		for(int i = 0; i < op.size(); i ++ ) {
			if(us[i] == 1) continue;
			us[i] = 1;
			
			vector<vector<vector<int>>> ans(7);
			for(auto & i : left) {
				if()
			};
		};
	};
	*/
};

int gl(vector<int> r) {
	//cout << "L: "  << r[0] << ' ' << r[1] << ' ' << r[2] << '\n';
	return getLightest(r[0], r[1], r[2]);
};
int gh(vector<int> r) {
	//cout << "H: "  << r[0] << ' ' << r[1] << ' ' << r[2] << '\n';
	return getHeaviest(r[0], r[1], r[2]);
};
int gm(vector<int> r) {
	//cout << "M: "  << r[0] << ' ' << r[1] << ' ' << r[2] << '\n';
	return getMedian(r[0], r[1], r[2]);
};
int gn(vector<int> r) {
	return getNextLightest(r[0], r[1], r[2], r[3]);
};
void as(vector<int> ans) {
	int a[6];
	for(int i = 0; i < 6; i ++ ) a[i] = ans[i];
	answer(a);
};

void orderCoins() {
	
	vector<int> p(6);
	iota(p.begin(), p.end(), 1);
	
	set< pair<int,vector<int>> > op2;
	do {
		pr.push_back(p);
		
		vector<int> a;
		for(int i = 1; i < 4; i ++ ) a.push_back(p[i]);
		sort(a.begin(), a.end());
		
		//for(int &i : a)i--;
		
		//op2.insert({0, {p[0], a[0], a[1], a[2]}});
		op2.insert({1, a});
		op2.insert({2, a});
		op2.insert({3, a});
		
	}while(next_permutation(p.begin(),p.end()));
	
	for(auto x : op2)op.push_back(x);
	
	vector<int> us(op.size());
	while(pr.size() > 1) {
		int mx = pr.size();
		int ans;
		for(int i = 0; i < (int)op.size(); i ++ )
		{
			if(us[i])continue;
			auto &o = op[i];
			
			int a = 0, b = 0, c = 0;
			for( auto p : pr){
				vector<int> r;
				for(int j : p) {
					if(j == o.second[0] || j == o.second[1] || j == o.second[2])
						r.push_back(j);
					
				};
				if(o.first == 1) {
					if(r[0] == o.second[0]) a ++ ;
					if(r[0] == o.second[1]) b ++ ;
					if(r[0] == o.second[2]) c ++ ;
				};
				if(o.first == 2) {
					if(r[2] == o.second[0]) a ++ ;
					if(r[2] == o.second[1]) b ++ ;
					if(r[2] == o.second[2]) c ++ ;
				};
				if(o.first == 3) {
					if(r[1] == o.second[0]) a ++ ;
					if(r[1] == o.second[1]) b ++ ;
					if(r[1] == o.second[2]) c ++ ;
				};
			
				//if(o.first == 1){
					//if(p[o.second[0]] < p[o.second[1]] and p[o.second[0]] < p[o.second[2]])
						//a++;
					//else if(p[o.second[1]] < p[o.second[2]])
						//b++;
					//else
						//c++;
					
				//}
				//if(o.first == 2) {
					//if(p[o.second[0]] > p[o.second[1]] and p[o.second[0]] > p[o.second[2]])
						//a++;
					//else if(p[o.second[1]] > p[o.second[2]])
						//b++;
					//else
						//c++;
				//}
				//if(o.first == 3) {
					//if((p[o.second[0]] > p[o.second[1]] and p[o.second[0]] < p[o.second[2]]) or (p[o.second[0]] > p[o.second[2]] and p[o.second[0]] < p[o.second[1]]))
						//a++;
					//else if((p[o.second[1]] > p[o.second[0]] and p[o.second[1]] < p[o.second[2]]) or (p[o.second[1]] > p[o.second[2]] and p[o.second[1]] < p[o.second[0]]))
						//b++;
					//else
						//c++;
				//};
			}
			
			if(mx > max(a, max(b,c))){
				mx = max(a, max(b,c));
				ans = i;
			}
		}
		if(op[ans].first == 1){
			int q = gl(op[ans].second);
			vector<vector<int>> np;
			
			for(auto i : pr) {
				vector<int> r;
				for(int j : i) {
					if(j == op[ans].second[0] || j == op[ans].second[1] || j == op[ans].second[2])
						r.push_back(j);
				};
				if(r[0] == q) {
					np.push_back(i);
				};
			};
			pr = np;
		}
		
		if(op[ans].first == 2){
			int q = gh(op[ans].second);
			vector<vector<int>> np;
			
			
			for(auto i : pr) {
				vector<int> r;
				for(int j : i) {
					if(j == op[ans].second[0] || j == op[ans].second[1] || j == op[ans].second[2])
						r.push_back(j);
				};
				if(r[2] == q) {
					np.push_back(i);
				};
			}
					
			pr = np;
		}
		
		if(op[ans].first == 3){
			int q = gm(op[ans].second);
			vector<vector<int>> np;
			
			for(auto i : pr){
				vector<int> r;
				for(int j : i) {
					if(j == op[ans].second[0] || j == op[ans].second[1] || j == op[ans].second[2])
						r.push_back(j);
				};
				if(r[1] == q) {
					np.push_back(i);
				};
			}
			pr = np;
		}
		//cout << pr.size() << '\n';
		us[ans] = 1;
	}
	as(pr[0]);
};


Compilation message (stderr)

/usr/bin/ld: /tmp/ccxgHWr9.o: in function `as(std::vector<int, std::allocator<int> >)':
scales.cpp:(.text+0x871): undefined reference to `answer(int*)'
/usr/bin/ld: /tmp/ccxgHWr9.o: in function `orderCoins()':
scales.cpp:(.text+0x17b6): undefined reference to `answer(int*)'
/usr/bin/ld: scales.cpp:(.text+0x1cd1): undefined reference to `getLightest(int, int, int)'
/usr/bin/ld: scales.cpp:(.text+0x20a4): undefined reference to `getHeaviest(int, int, int)'
/usr/bin/ld: scales.cpp:(.text+0x2543): undefined reference to `getMedian(int, int, int)'
/usr/bin/ld: /tmp/ccxgHWr9.o: in function `gl(std::vector<int, std::allocator<int> >)':
scales.cpp:(.text+0x7d0): undefined reference to `getLightest(int, int, int)'
/usr/bin/ld: /tmp/ccxgHWr9.o: in function `gh(std::vector<int, std::allocator<int> >)':
scales.cpp:(.text+0x7f0): undefined reference to `getHeaviest(int, int, int)'
/usr/bin/ld: /tmp/ccxgHWr9.o: in function `gm(std::vector<int, std::allocator<int> >)':
scales.cpp:(.text+0x810): undefined reference to `getMedian(int, int, int)'
/usr/bin/ld: /tmp/ccxgHWr9.o: in function `gn(std::vector<int, std::allocator<int> >)':
scales.cpp:(.text+0x833): undefined reference to `getNextLightest(int, int, int, int)'
/usr/bin/ld: /tmp/ccfUZZq0.o: in function `main':
grader.c:(.text.startup+0x83): undefined reference to `init'
/usr/bin/ld: grader.c:(.text.startup+0x101): undefined reference to `orderCoins'
collect2: error: ld returned 1 exit status