Submission #139773

# Submission time Handle Problem Language Result Execution time Memory
139773 2019-08-01T11:26:48 Z dndhk Broken Device (JOI17_broken_device) C++14
100 / 100
44 ms 3320 KB
#include "Annalib.h"
#include <bits/stdc++.h>

#define pb push_back
#define all(v) ((v).begin(), (v).end())
#define sortv(v) sort(all(v))
#define sz(v) ((int)(v).size())
#define uniqv(v) (v).erase(unique(all(v)), (v).end())
#define umax(a, b) (a)=max((a), (b))
#define umin(a, b) (a)=min((a), (b))
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define rep(i,n) FOR(i,1,n)
#define rep0(i,n) FOR(i,0,(int)(n)-1)
#define FI first
#define SE second
#define INF 2000000000
#define INFLL 1000000000000000000LL


using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAX_N = 150;

int chk[MAX_N+1];

int ii=0;
void S(int x, int y, int z){
	Set(ii, x); Set(ii+1, y); Set(ii+2, z);
	ii+=3;
}

void Anna(int N, long long X, int K, int P[]){
	ii = 0;
	for(int i=0; i<N; i++)	chk[i] = false;
	for(int i=0; i<K; i++){
		chk[P[i]] = 1;
	}
	int x = 0;
	for(int i = 0; i < N; i+=3){
		if(chk[i] + chk[i+1] + chk[i+2] >= 2){
			S(0, 0, 0);
			continue;
		}
		if(chk[i]+chk[i+1]+chk[i+2] == 1){
			if(chk[i]){
				if(X%2==1){
					if(X%4==1){
						S(0, 0, 1);
					}else{
						S(0, 1, 1);
					}
					X/=(ll)4;
				}else{
					S(0, 1, 0);
					X/=(ll)2;
				}
			}else if(chk[i+1]){
				if(X%2==1){
					S(1, 0, 0);
				}else{
					S(1, 0, 1);
				}
				X/=(ll)2;
			}else{
				if(X%2==1){
					S(1, 0, 0);
				}else{
					S(0, 1, 0);	
				}	
				X/=(ll)2;
			}
		}else{
			if(X%4==0){
				S(1, 1, 1);
			}else if(X%4==1){
				S(0, 0, 1);
			}else if(X%4==2){
				S(1, 1, 0);
			}else{
				S(0, 1, 1);
			}
			X/=(ll)4;
		}
	}
}
#include "Brunolib.h"
#include <bits/stdc++.h>

#define pb push_back
#define all(v) ((v).begin(), (v).end())
#define sortv(v) sort(all(v))
#define sz(v) ((int)(v).size())
#define uniqv(v) (v).erase(unique(all(v)), (v).end())
#define umax(a, b) (a)=max((a), (b))
#define umin(a, b) (a)=min((a), (b))
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define rep(i,n) FOR(i,1,n)
#define rep0(i,n) FOR(i,0,(int)(n)-1)
#define FI first
#define SE second
#define INF 2000000000
#define INFLL 1000000000000000000LL


using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;


ll ans = 0;
ll two = 1;

void make(int x, int y){
	ans = ans + two * (int)x;
	two = two*(int)y;
}

long long Bruno( int N, int A[] ){
	ans = 0; two = 1;
	for(int i=0; i<N; i+=3){
		int k = A[i]*4 + A[i+1]*2 + A[i+2];
		if(k==0)	make(0, 1);
		else if(k==1)	make(1, 4);
		else if(k==2)	make(0, 2);
		else if(k==3)	make(3, 4);
		else if(k==4)	make(1, 2);
		else if(k==5)	make(0, 2);
		else if(k==6)	make(2, 4);
		else if(k==7)	make(0, 4);
	}
	return ans;
}

Compilation message

Anna.cpp: In function 'void Anna(int, long long int, int, int*)':
Anna.cpp:41:6: warning: unused variable 'x' [-Wunused-variable]
  int x = 0;
      ^
# Verdict Execution time Memory Grader output
1 Correct 40 ms 3312 KB Output is correct - L* = 40
2 Correct 41 ms 3256 KB Output is correct - L* = 40
3 Correct 40 ms 3280 KB Output is correct - L* = 40
4 Correct 40 ms 3312 KB Output is correct - L* = 40
5 Correct 41 ms 3312 KB Output is correct - L* = 40
6 Correct 41 ms 3320 KB Output is correct - L* = 40
7 Correct 40 ms 3312 KB Output is correct - L* = 40
8 Correct 40 ms 3312 KB Output is correct - L* = 40
9 Correct 40 ms 3312 KB Output is correct - L* = 40
10 Correct 41 ms 3312 KB Output is correct - L* = 40
11 Correct 41 ms 3312 KB Output is correct - L* = 40
12 Correct 41 ms 3312 KB Output is correct - L* = 40
13 Correct 40 ms 3312 KB Output is correct - L* = 40
14 Correct 41 ms 3312 KB Output is correct - L* = 40
15 Correct 39 ms 3312 KB Output is correct - L* = 40
16 Correct 39 ms 3152 KB Output is correct - L* = 40
17 Correct 41 ms 3312 KB Output is correct - L* = 40
18 Correct 39 ms 3256 KB Output is correct - L* = 40
19 Correct 40 ms 3312 KB Output is correct - L* = 40
20 Correct 40 ms 3312 KB Output is correct - L* = 40
21 Correct 39 ms 3056 KB Output is correct - L* = 40
22 Correct 40 ms 3056 KB Output is correct - L* = 40
23 Correct 41 ms 3056 KB Output is correct - L* = 40
24 Correct 41 ms 3256 KB Output is correct - L* = 40
25 Correct 41 ms 3312 KB Output is correct - L* = 40
26 Correct 41 ms 3312 KB Output is correct - L* = 40
27 Correct 41 ms 3312 KB Output is correct - L* = 40
28 Correct 44 ms 3064 KB Output is correct - L* = 40
29 Correct 41 ms 3056 KB Output is correct - L* = 40
30 Correct 41 ms 3312 KB Output is correct - L* = 40
31 Correct 40 ms 3096 KB Output is correct - L* = 40
32 Correct 41 ms 3216 KB Output is correct - L* = 40
33 Correct 40 ms 3312 KB Output is correct - L* = 40
34 Correct 40 ms 3056 KB Output is correct - L* = 40
35 Correct 40 ms 3192 KB Output is correct - L* = 40
36 Correct 40 ms 3128 KB Output is correct - L* = 40
37 Correct 40 ms 3312 KB Output is correct - L* = 40
38 Correct 39 ms 3304 KB Output is correct - L* = 40
39 Correct 40 ms 3056 KB Output is correct - L* = 40
40 Correct 39 ms 3312 KB Output is correct - L* = 40