답안 #131747

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
131747 2019-07-17T14:15:37 Z MohamedAhmed04 Broken Device (JOI17_broken_device) C++14
100 / 100
61 ms 3064 KB
#include "Annalib.h"
#include <bits/stdc++.h>

using namespace std ;

void Anna( int N, long long X, int K, int P[] )
{
	srand(543739) ;
	vector<int>v ;
	for(int i = 0 ; i < N ; ++i)
		v.push_back(i) ;
	random_shuffle(v.begin() , v.end()) ;
	int mark[N+1] ;
	for(int i = 0 ; i <= N ; ++i)
		mark[i] = 0 ;
	for(int i = 0 ; i < K ; ++i)
		mark[P[i]] = 1;
	int last = -1 ;
	for(int i = 0 ; i < N ; i += 2)
	{
		last = i+1 ;
		if(X == 0)
		{
			Set(v[i] , 0) ;
			Set(v[i+1] , 0) ;
			continue ;
		}
		int now = X % 3 ;
		if(now == 0 && mark[v[i+1]] == 0)
		{
			Set(v[i] , 0) ;
			Set(v[i+1] , 1) ;
			X /= 3 ;
			continue ;
		}
		if(now == 1 && mark[v[i]] == 0)
		{
			Set(v[i] , 1) ;
			Set(v[i+1] , 0) ;
			X /= 3 ;
			continue ;
		}
		if(now == 2 && mark[v[i]] == 0 && mark[v[i+1]] == 0)
		{
			Set(v[i] , 1) ;
			Set(v[i+1] , 1) ;
			X /= 3 ;
			continue ;
		}
		Set(v[i] , 0) ;
		Set(v[i+1] , 0) ;
	}
	if(last < N-1)
		Set(v[N-1] , 0) ;
}
#include "Brunolib.h"
#include <bits/stdc++.h>

using namespace std ;

long long Bruno( int N, int A[] )
{
   srand(543739) ;
   vector<int>v ;
  for(int i = 0 ; i < N ; ++i)
    v.push_back(i) ;
  random_shuffle(v.begin() , v.end()) ;
  vector<int>v1 ;
   long long ans = 0ll ;
   for(int i = 0 ; i < N-1 ; i += 2)
   {
      if(A[v[i]] == 0 && A[v[i+1]] == 0)
        continue ;
      if(A[v[i]] == 0 && A[v[i+1]] == 1)
        v1.push_back(0) ;
      else if(A[v[i]] == 1 && A[v[i+1]] == 0)
        v1.push_back(1) ;
      else if(A[v[i]] == 1 && A[v[i+1]] == 1)
        v1.push_back(2) ;
   }
   reverse(v1.begin() , v1.end()) ;
   for(auto &i : v1)
      ans = ans * 3ll + i * 1ll ;
   return ans;    
}
# 결과 실행 시간 메모리 Grader output
1 Correct 61 ms 3056 KB Output is correct - L* = 40
2 Correct 56 ms 3056 KB Output is correct - L* = 40
3 Correct 55 ms 3064 KB Output is correct - L* = 40
4 Correct 55 ms 3056 KB Output is correct - L* = 40
5 Correct 57 ms 3056 KB Output is correct - L* = 40
6 Correct 55 ms 3056 KB Output is correct - L* = 40
7 Correct 56 ms 3056 KB Output is correct - L* = 40
8 Correct 56 ms 3056 KB Output is correct - L* = 40
9 Correct 56 ms 3056 KB Output is correct - L* = 40
10 Correct 56 ms 3056 KB Output is correct - L* = 40
11 Correct 56 ms 3056 KB Output is correct - L* = 40
12 Correct 55 ms 3056 KB Output is correct - L* = 40
13 Correct 55 ms 3056 KB Output is correct - L* = 40
14 Correct 55 ms 3056 KB Output is correct - L* = 40
15 Correct 55 ms 3056 KB Output is correct - L* = 40
16 Correct 55 ms 3056 KB Output is correct - L* = 40
17 Correct 56 ms 3056 KB Output is correct - L* = 40
18 Correct 55 ms 3056 KB Output is correct - L* = 40
19 Correct 55 ms 3056 KB Output is correct - L* = 40
20 Correct 56 ms 3056 KB Output is correct - L* = 40
21 Correct 56 ms 3056 KB Output is correct - L* = 40
22 Correct 55 ms 3056 KB Output is correct - L* = 40
23 Correct 56 ms 3056 KB Output is correct - L* = 40
24 Correct 56 ms 3056 KB Output is correct - L* = 40
25 Correct 56 ms 3056 KB Output is correct - L* = 40
26 Correct 56 ms 3000 KB Output is correct - L* = 40
27 Correct 56 ms 3056 KB Output is correct - L* = 40
28 Correct 56 ms 3056 KB Output is correct - L* = 40
29 Correct 55 ms 3056 KB Output is correct - L* = 40
30 Correct 56 ms 3056 KB Output is correct - L* = 40
31 Correct 56 ms 3056 KB Output is correct - L* = 40
32 Correct 56 ms 3056 KB Output is correct - L* = 40
33 Correct 55 ms 3056 KB Output is correct - L* = 40
34 Correct 55 ms 3056 KB Output is correct - L* = 40
35 Correct 57 ms 3056 KB Output is correct - L* = 40
36 Correct 55 ms 3056 KB Output is correct - L* = 40
37 Correct 55 ms 3056 KB Output is correct - L* = 40
38 Correct 56 ms 3056 KB Output is correct - L* = 40
39 Correct 55 ms 3056 KB Output is correct - L* = 40
40 Correct 56 ms 3064 KB Output is correct - L* = 40