Submission #16551

# Submission time Handle Problem Language Result Execution time Memory
16551 2015-08-27T14:27:52 Z gs13068 Scales (IOI15_scales) C++
0 / 100
0 ms 1128 KB
#include "scales.h"
#include <cstdio>
#include <algorithm>

void init(int T){}

int p[777];
int t[7];

int testMed(int a,int b,int c)
{
	int i,j,k,r=0;
	for(i=0;i<720;i++)if(p[i])
	{
		for(j=1;j<=6;j++)t[j]=j;
		k=i;
		for(j=1;j<=6;j++)
		{
			std::swap(t[j],t[k%j+1]);
            k/=j;
		}

		if((t[a]<t[b]&&t[b]<t[c])||(t[a]>t[b]&&t[b]>t[c]))r++;
	}
	return r;
}

void orderCoins()
{
	int i,j,k,a,b,c,r=0;
	a=getLightest(1,2,3);
    b=getNextLightest(4,5,6,a);
	for(i=0;i<720;i++)
	{
		for(j=1;j<=6;j++)t[j]=j;
		k=i;
		for(j=1;j<=6;j++)
		{
			std::swap(t[j],t[k%j+1]);
            k/=j;
		}

		p[i]=0;

		k=0;
		for(j=1;j<=3;j++)if(!k||t[j]<t[k])k=j;
		if(k!=a)continue;

		k=0;
		for(j=4;j<=6;j++)if(t[j]>t[a]&&(!k||t[j]<t[k]))k=j;
		if(!k)for(j=4;j<=6;j++)if(!k||t[j]<t[k])k=j;
		if(k!=b)continue;

		p[i]=1;
		r++;
	}

	printf("%d %d\n",a,b);

	for(;r>1;)
	{
		for(i=1;i<=6;i++)
		{
			for(j=1;j<i;j++)
			{
				for(k=1;k<j;k++)if(testMed(i,j,k)<=(r+2)/3&&testMed(j,k,i)<=(r+2)/3&&testMed(k,i,j)<=(r+2)/3)printf("%d %d %d\n",i,j,k);
				if(k<j)break;
			}
			if(j<i)break;
		}

		if(r==80)i=2,j=5,k=6;

		printf("!!!! %d %d %d\n",testMed(i,j,k),testMed(j,k,i),testMed(k,i,j));

		b=getMedian(i,j,k);
		if(b==i)a=j,c=k;
		if(b==j)a=i,c=k;
		if(b==k)a=i,c=j;
		r=0;
		for(i=0;i<720;i++)if(p[i])
		{
			for(j=1;j<=6;j++)t[j]=j;
			k=i;
			for(j=1;j<=6;j++)
			{
				std::swap(t[j],t[k%j+1]);
				k/=j;
			}

			p[i]=0;
			if((t[a]<t[b]&&t[b]<t[c])||(t[a]>t[b]&&t[b]>t[c]))
			{
				p[i]=1;
				r++;
			}
		}
	}
}

Compilation message

scales.cpp:5:15: warning: unused parameter 'T' [-Wunused-parameter]
 void init(int T){}
               ^
scales.cpp: In function 'void orderCoins()':
scales.cpp:92:51: warning: 'c' may be used uninitialized in this function [-Wmaybe-uninitialized]
    if((t[a]<t[b]&&t[b]<t[c])||(t[a]>t[b]&&t[b]>t[c]))
                                                   ^

# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 1128 KB Execution killed because of forbidden syscall gettid (186)
2 Runtime error 0 ms 1128 KB Execution killed because of forbidden syscall gettid (186)
3 Runtime error 0 ms 1128 KB Execution killed because of forbidden syscall gettid (186)
4 Runtime error 0 ms 1128 KB Execution killed because of forbidden syscall gettid (186)
5 Runtime error 0 ms 1128 KB Execution killed because of forbidden syscall gettid (186)
6 Runtime error 0 ms 1128 KB Execution killed because of forbidden syscall gettid (186)
7 Runtime error 0 ms 1128 KB Execution killed because of forbidden syscall gettid (186)
8 Runtime error 0 ms 1128 KB Execution killed because of forbidden syscall gettid (186)
9 Runtime error 0 ms 1128 KB Execution killed because of forbidden syscall gettid (186)
10 Runtime error 0 ms 1128 KB Execution killed because of forbidden syscall gettid (186)
11 Runtime error 0 ms 1128 KB Execution killed because of forbidden syscall gettid (186)
12 Runtime error 0 ms 1128 KB Execution killed because of forbidden syscall gettid (186)
13 Runtime error 0 ms 1128 KB Execution killed because of forbidden syscall gettid (186)
14 Runtime error 0 ms 1128 KB Execution killed because of forbidden syscall gettid (186)
15 Runtime error 0 ms 1128 KB Execution killed because of forbidden syscall gettid (186)
16 Runtime error 0 ms 1128 KB Execution killed because of forbidden syscall gettid (186)
17 Runtime error 0 ms 1128 KB Execution killed because of forbidden syscall gettid (186)
18 Runtime error 0 ms 1128 KB Execution killed because of forbidden syscall gettid (186)
19 Runtime error 0 ms 1128 KB Execution killed because of forbidden syscall gettid (186)
20 Runtime error 0 ms 1128 KB Execution killed because of forbidden syscall gettid (186)
21 Runtime error 0 ms 1128 KB Execution killed because of forbidden syscall gettid (186)
22 Runtime error 0 ms 1128 KB Execution killed because of forbidden syscall gettid (186)
23 Runtime error 0 ms 1128 KB Execution killed because of forbidden syscall gettid (186)
24 Runtime error 0 ms 1128 KB Execution killed because of forbidden syscall gettid (186)
25 Runtime error 0 ms 1128 KB Execution killed because of forbidden syscall gettid (186)
26 Runtime error 0 ms 1128 KB Execution killed because of forbidden syscall gettid (186)
27 Runtime error 0 ms 1128 KB Execution killed because of forbidden syscall gettid (186)
28 Runtime error 0 ms 1128 KB Execution killed because of forbidden syscall gettid (186)
29 Runtime error 0 ms 1128 KB Execution killed because of forbidden syscall gettid (186)
30 Runtime error 0 ms 1128 KB Execution killed because of forbidden syscall gettid (186)
31 Runtime error 0 ms 1128 KB Execution killed because of forbidden syscall gettid (186)
32 Runtime error 0 ms 1128 KB Execution killed because of forbidden syscall gettid (186)
33 Runtime error 0 ms 1128 KB Execution killed because of forbidden syscall gettid (186)
34 Runtime error 0 ms 1128 KB Execution killed because of forbidden syscall gettid (186)
35 Runtime error 0 ms 1128 KB Execution killed because of forbidden syscall gettid (186)
36 Runtime error 0 ms 1128 KB Execution killed because of forbidden syscall gettid (186)
37 Runtime error 0 ms 1128 KB Execution killed because of forbidden syscall gettid (186)
38 Runtime error 0 ms 1128 KB Execution killed because of forbidden syscall gettid (186)
39 Runtime error 0 ms 1128 KB Execution killed because of forbidden syscall gettid (186)
40 Runtime error 0 ms 1128 KB Execution killed because of forbidden syscall gettid (186)