답안 #131722

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
131722 2019-07-17T13:26:20 Z Mahmoud_Adel Broken Device (JOI17_broken_device) C++14
100 / 100
63 ms 3232 KB
#include <bits/stdc++.h>
#include "Annalib.h"
typedef long long ll;
using namespace std;
int mark[151];
ll power(ll x, ll y)
{
	if(y == 0) return 1;
	ll ret = 1;
	while(y--) ret *= x;
	return ret;
}
void Anna(int n, long long x, int k, int p[] )
{
	srand(3214354);
	vector<int> v;
	for(int i=0; i<150; i++) v.push_back(i);
	random_shuffle(v.begin(), v.end());
	ll temp = x, cnt = 0;
	memset(mark, 0, sizeof mark);
	for(int i=0; i<k; i++) mark[p[i]] = 1;
	ll a[38];
	for(ll i=37; i>=0; i--)
	{
		if(temp >= power(3, i)*2) temp -= power(3, i)*2, a[i] = 2;
		else if(temp >= power(3, i)) temp -= power(3, i), a[i] = 1;
		else a[i] = 0;
	}
	for(int i=0; i<n; i+=2)
	{
		if((mark[v[i]] && mark[v[i+1]]) || cnt > 37) Set(v[i], 0), Set(v[i+1], 0);
		else
		{
			if(a[cnt] == 2 && (!mark[v[i]] && !mark[v[i+1]])) Set(v[i], 1), Set(v[i+1], 1);
			else if(a[cnt] == 2) Set(v[i], 0), Set(v[i+1], 0), cnt--;
			else if(a[cnt] == 1 && !mark[v[i]]) Set(v[i], 1), Set(v[i+1], 0);
			else if(a[cnt] == 1) Set(v[i], 0), Set(v[i+1], 0), cnt--;
			else if(!mark[v[i+1]]) Set(v[i], 0), Set(v[i+1], 1);
			else Set(v[i], 0), Set(v[i+1], 0), cnt--;
			cnt++;
		}
	}
}
#include "Brunolib.h"
#include <bits/stdc++.h>
//~ #include "Anna.cpp"
//~ #include "grader.cpp"
typedef long long ll;
using namespace std;
ll power(ll x, ll y)
{
	if(y == 0) return 1;
	ll ret = 1;
	while(y--) ret *= x;
	return ret;
}
long long Bruno(int n, int a[] )
{
	srand(3214354);
	vector<int> v;
	for(int i=0; i<150; i++) v.push_back(i);
	random_shuffle(v.begin(), v.end());
	ll cnt = 0;
	ll x = 0;
	for(int i=0; i<n; i+=2)
	{
		if(!a[v[i]] && !a[v[i+1]]) continue;
		int b;
		if(a[v[i]] == 1 && a[v[i+1]] == 1) b = 2;
		else if(a[v[i]] == 1) b = 1;
		else b = 0;
		x += b*power(3, cnt++);
	}
	return x;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 57 ms 3064 KB Output is correct - L* = 40
2 Correct 57 ms 3056 KB Output is correct - L* = 40
3 Correct 57 ms 3056 KB Output is correct - L* = 40
4 Correct 56 ms 3056 KB Output is correct - L* = 40
5 Correct 57 ms 3056 KB Output is correct - L* = 40
6 Correct 57 ms 3056 KB Output is correct - L* = 40
7 Correct 57 ms 3056 KB Output is correct - L* = 40
8 Correct 63 ms 3032 KB Output is correct - L* = 40
9 Correct 57 ms 3056 KB Output is correct - L* = 40
10 Correct 57 ms 3056 KB Output is correct - L* = 40
11 Correct 59 ms 3000 KB Output is correct - L* = 40
12 Correct 57 ms 3056 KB Output is correct - L* = 40
13 Correct 57 ms 3056 KB Output is correct - L* = 40
14 Correct 57 ms 3056 KB Output is correct - L* = 40
15 Correct 57 ms 3056 KB Output is correct - L* = 40
16 Correct 59 ms 3056 KB Output is correct - L* = 40
17 Correct 57 ms 3056 KB Output is correct - L* = 40
18 Correct 57 ms 3056 KB Output is correct - L* = 40
19 Correct 57 ms 3056 KB Output is correct - L* = 40
20 Correct 57 ms 3056 KB Output is correct - L* = 40
21 Correct 57 ms 3232 KB Output is correct - L* = 40
22 Correct 57 ms 3064 KB Output is correct - L* = 40
23 Correct 57 ms 3056 KB Output is correct - L* = 40
24 Correct 59 ms 3144 KB Output is correct - L* = 40
25 Correct 59 ms 3056 KB Output is correct - L* = 40
26 Correct 61 ms 3008 KB Output is correct - L* = 40
27 Correct 61 ms 3056 KB Output is correct - L* = 40
28 Correct 57 ms 3056 KB Output is correct - L* = 40
29 Correct 56 ms 3056 KB Output is correct - L* = 40
30 Correct 57 ms 3056 KB Output is correct - L* = 40
31 Correct 56 ms 3056 KB Output is correct - L* = 40
32 Correct 57 ms 3008 KB Output is correct - L* = 40
33 Correct 57 ms 3056 KB Output is correct - L* = 40
34 Correct 56 ms 3056 KB Output is correct - L* = 40
35 Correct 56 ms 3056 KB Output is correct - L* = 40
36 Correct 57 ms 3056 KB Output is correct - L* = 40
37 Correct 60 ms 3064 KB Output is correct - L* = 40
38 Correct 62 ms 3056 KB Output is correct - L* = 40
39 Correct 62 ms 3056 KB Output is correct - L* = 40
40 Correct 56 ms 3056 KB Output is correct - L* = 40