Submission #395810

# Submission time Handle Problem Language Result Execution time Memory
395810 2021-04-29T00:52:34 Z ScarletS Scales (IOI15_scales) C++17
0 / 100
1 ms 460 KB
#include <bits/stdc++.h>
#include "scales.h"
#define ll long long
#define sz(x) (int)(x).size()
using namespace std;

bitset<7> done, l[7], available;

void init(int T) {
    /* ... */
}

void orderCoins() {
    /* ... */
    int x, y, W[] = {0, 0, 0, 0, 0, 0};
    for (int i=1;i<7;++i)
    {
    	done[i]=0;
    	for (int j=1;j<7;++j)
    		l[i][j]=0;
    }
    x=getLightest(1,2,3);
    y=getLightest(4,5,6);
    for (int i=1;i<=3;++i)
    	l[x][i]=1;
    for (int i=4;i<=6;++i)
    	l[y][i]=1;
    for (int i=1;i<=6;++i)
    	if (x!=i&&y!=i)
    	{
    		x=getLightest(i,x,y);
    		W[0]=x;
    		break;
    	}
    for (int N=5;N>0;--N)
    {
    	vector<int> v;
    	for (int i=1;i<7;++i)
    		available[i]=done[i]^1;
    	for (int i=1;i<7;++i)
    		for (int j=1;j<7;++j)
    			if (i!=j&&available[i]&&available[j]&&l[i][j])
    				available[i]=0;
    	for (int i=1;i<7;++i)
    		if (available[i])
    			v.push_back(i);
    	if (sz(v)==1)
    		W[N]=v[0];
    	else if (sz(v)==2)
    	{
    		x=getHeaviest(v[0],v[1],W[0]);
    		W[N]=x;
    	}
    	else if (sz(v)==3)
    	{
    		x=getHeaviest(v[0],v[1],v[2]);
    		W[N]=x;
    	}
    	else if (sz(v)==4)
    	{
    		x=getHeaviest(v[0],v[1],v[2]);
    		for (int i=0;i<3;++i)
    			l[v[i]][x]=1;
    		for (int i=0;i<3;++i)
    			if (v[i]!=x)
    			{
    				W[N]=getHeaviest(v[3],x,v[i]);
    				break;
    			}
    	}
    	else
    	{
    		x=getHeaviest(v[0],v[1],v[2]);
    		for (int i=0;i<3;++i)
    			l[v[i]][x]=1;
    		W[N]=getHeaviest(v[3],v[4],x);
    	}
    	done[W[N]]=1;
    }
    answer(W);
}

Compilation message

scales.cpp: In function 'void init(int)':
scales.cpp:9:15: warning: unused parameter 'T' [-Wunused-parameter]
    9 | void init(int T) {
      |           ~~~~^
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 332 KB Execution killed with signal 6
2 Runtime error 1 ms 336 KB Execution killed with signal 6
3 Runtime error 1 ms 332 KB Execution killed with signal 6
4 Runtime error 1 ms 332 KB Execution killed with signal 6
5 Runtime error 1 ms 332 KB Execution killed with signal 6
6 Runtime error 1 ms 332 KB Execution killed with signal 6
7 Runtime error 1 ms 332 KB Execution killed with signal 6
8 Runtime error 1 ms 332 KB Execution killed with signal 6
9 Runtime error 1 ms 332 KB Execution killed with signal 6
10 Runtime error 1 ms 332 KB Execution killed with signal 6
11 Runtime error 1 ms 332 KB Execution killed with signal 6
12 Runtime error 1 ms 332 KB Execution killed with signal 6
13 Runtime error 1 ms 336 KB Execution killed with signal 6
14 Runtime error 1 ms 424 KB Execution killed with signal 6
15 Runtime error 1 ms 332 KB Execution killed with signal 6
16 Runtime error 1 ms 420 KB Execution killed with signal 6
17 Runtime error 1 ms 332 KB Execution killed with signal 6
18 Runtime error 1 ms 332 KB Execution killed with signal 6
19 Runtime error 1 ms 420 KB Execution killed with signal 6
20 Runtime error 1 ms 332 KB Execution killed with signal 6
21 Runtime error 1 ms 332 KB Execution killed with signal 6
22 Runtime error 1 ms 332 KB Execution killed with signal 6
23 Runtime error 1 ms 332 KB Execution killed with signal 6
24 Runtime error 1 ms 332 KB Execution killed with signal 6
25 Runtime error 1 ms 332 KB Execution killed with signal 6
26 Runtime error 1 ms 332 KB Execution killed with signal 6
27 Runtime error 1 ms 332 KB Execution killed with signal 6
28 Runtime error 1 ms 332 KB Execution killed with signal 6
29 Runtime error 1 ms 336 KB Execution killed with signal 6
30 Runtime error 1 ms 424 KB Execution killed with signal 6
31 Runtime error 1 ms 332 KB Execution killed with signal 6
32 Runtime error 1 ms 332 KB Execution killed with signal 6
33 Runtime error 1 ms 332 KB Execution killed with signal 6
34 Runtime error 1 ms 332 KB Execution killed with signal 6
35 Runtime error 1 ms 332 KB Execution killed with signal 6
36 Runtime error 1 ms 332 KB Execution killed with signal 6
37 Runtime error 1 ms 332 KB Execution killed with signal 6
38 Runtime error 1 ms 332 KB Execution killed with signal 6
39 Runtime error 1 ms 460 KB Execution killed with signal 6
40 Runtime error 1 ms 332 KB Execution killed with signal 6