답안 #231896

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
231896 2020-05-15T09:16:54 Z jiahng Broken Device (JOI17_broken_device) C++17
0 / 100
62 ms 3312 KB
#include "Annalib.h"
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector <ll> vi;
typedef vector <pi> vpi;
#define f first
#define s second
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0)
#define maxn 151



void Anna(int N, long long X, int K, int P[]){
	bool broken[maxn];
	FOR(i,0,N-1) broken[i] = 0;
	
	FOR(i,0,K-1) broken[P[i]] = 1;
	int idx = 0;
	
	for (int i = 0; i < 150; i += 3){
		int num = 0;
		bool A[3];
		A[0] = A[1] = A[2] = 0;
		
		FOR(j,i,i+2){
			if (broken[j]){
				A[j-i] = 1;
				num++;
			}
		}

		if (num > 1){
			FOR(j,i,i+2) Set(j,0);
			continue;
		}else if (num == 1){
			if ((X & (1<<idx)) == 1){
				if (!A[2]){
					Set(i,0); Set(i+1,0); Set(i+2,1);
				}else{
					Set(i,1); Set(i+1,1); Set(i+2,0);
				}
				idx++;
			}else{
				if (!A[1]){
					Set(i,0); Set(i+1,1); Set(i+2,0);
					idx++;
				}else{
					if (X & (1<<(idx+1)) == 1){
						Set(i,0); Set(i+1,0); Set(i+2,1);
					}else{
						Set(i,1); Set(i+1,0); Set(i+2,1);
					}
					idx += 2;
				}
			}
		}else{
			string a = "";
			if (X & (1<<idx) == 1) a += '1';
			else a += '0';
			
			if (X & (1<<(idx+1)) == 1) a += '1';
			else a += '0';
			
			if (a == "00"){
				Set(i,1); Set(i+1,0); Set(i+2,1);
			}else if (a == "01"){
				Set(i,1); Set(i+1,0); Set(i+2,0);
			}else if (a == "10"){
				Set(i,0); Set(i+1,1); Set(i+2,1);
			}else{
				Set(i,1); Set(i+1,1); Set(i+2,1);
			}
			idx += 2;
		}
	}
			
		  
}
#include "Brunolib.h"
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector <ll> vi;
typedef vector <pi> vpi;
#define f first
#define s second
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0)


long long Bruno(int N, int A[]){
  string ans = "";
  
  for (int i = 0; i < 150; i+=3){
	  string cur = "";
	  FOR(j,i,i+2){
		  if (A[j] == 1) cur += '1';
		  else cur += '0';
	  }

	  if (cur == "000") continue;
	  else if (cur == "001" || cur == "110") ans += '1';
	  else if (cur == "010") ans += '0';
	  else if (cur == "111") ans += "11";
	  else if (cur == "011") ans += "10";
	  else if (cur == "100") ans += "01";
	  else ans += "00";
  }
  
  ll lans = 0;
 
  FOR(i,0,ans.size() - 1){
	  if (ans[i] == '1') lans |= (1<<i);
  }
  return lans;
  
}

Compilation message

Anna.cpp: In function 'void Anna(int, long long int, int, int*)':
Anna.cpp:59:27: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
      if (X & (1<<(idx+1)) == 1){
              ~~~~~~~~~~~~~^~~~
Anna.cpp:69:21: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
    if (X & (1<<idx) == 1) a += '1';
            ~~~~~~~~~^~~~
Anna.cpp:72:25: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
    if (X & (1<<(idx+1)) == 1) a += '1';
            ~~~~~~~~~~~~~^~~~
# 결과 실행 시간 메모리 Grader output
1 Partially correct 51 ms 3056 KB Output isn't correct - L* = 0
2 Partially correct 53 ms 3072 KB Output isn't correct - L* = 0
3 Partially correct 50 ms 3072 KB Output isn't correct - L* = 0
4 Partially correct 51 ms 3312 KB Output isn't correct - L* = 0
5 Partially correct 54 ms 3056 KB Output isn't correct - L* = 0
6 Partially correct 51 ms 3072 KB Output isn't correct - L* = 0
7 Partially correct 50 ms 3056 KB Output isn't correct - L* = 0
8 Partially correct 50 ms 3056 KB Output isn't correct - L* = 0
9 Partially correct 56 ms 3056 KB Output isn't correct - L* = 0
10 Partially correct 51 ms 3072 KB Output isn't correct - L* = 0
11 Partially correct 51 ms 3056 KB Output isn't correct - L* = 0
12 Partially correct 50 ms 3064 KB Output isn't correct - L* = 0
13 Partially correct 62 ms 3072 KB Output isn't correct - L* = 0
14 Partially correct 51 ms 3072 KB Output isn't correct - L* = 0
15 Partially correct 49 ms 3072 KB Output isn't correct - L* = 0
16 Partially correct 49 ms 3072 KB Output isn't correct - L* = 0
17 Partially correct 51 ms 3056 KB Output isn't correct - L* = 0
18 Partially correct 51 ms 3056 KB Output isn't correct - L* = 0
19 Partially correct 50 ms 3072 KB Output isn't correct - L* = 0
20 Partially correct 52 ms 3056 KB Output isn't correct - L* = 0
21 Partially correct 50 ms 3072 KB Output isn't correct - L* = 0
22 Partially correct 50 ms 3072 KB Output isn't correct - L* = 0
23 Partially correct 51 ms 3072 KB Output isn't correct - L* = 0
24 Partially correct 53 ms 3056 KB Output isn't correct - L* = 0
25 Partially correct 53 ms 3056 KB Output isn't correct - L* = 0
26 Partially correct 51 ms 3072 KB Output isn't correct - L* = 0
27 Partially correct 56 ms 3072 KB Output isn't correct - L* = 0
28 Partially correct 53 ms 3128 KB Output isn't correct - L* = 0
29 Partially correct 51 ms 3072 KB Output isn't correct - L* = 0
30 Partially correct 51 ms 3072 KB Output isn't correct - L* = 0
31 Partially correct 50 ms 3072 KB Output isn't correct - L* = 0
32 Partially correct 52 ms 3072 KB Output isn't correct - L* = 0
33 Partially correct 49 ms 3056 KB Output isn't correct - L* = 0
34 Partially correct 50 ms 3072 KB Output isn't correct - L* = 0
35 Partially correct 49 ms 3072 KB Output isn't correct - L* = 0
36 Partially correct 53 ms 3072 KB Output isn't correct - L* = 0
37 Partially correct 53 ms 3072 KB Output isn't correct - L* = 0
38 Partially correct 50 ms 3072 KB Output isn't correct - L* = 0
39 Partially correct 50 ms 3072 KB Output isn't correct - L* = 0
40 Partially correct 50 ms 3072 KB Output isn't correct - L* = 0