답안 #902659

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
902659 2024-01-10T22:56:57 Z nguyentunglam Broken Device (JOI17_broken_device) C++17
55 / 100
40 ms 2692 KB
#include "Annalib.h"
#include<bits/stdc++.h>
using namespace std;

namespace {
  mt19937 rng(1);
}

void Anna( int n, long long x, int k, int p[] ){
  vector<bool> broken(n);
  vector<int> order(n);
  for(int i = 0; i < n; i++) order[i] = i;
  shuffle(order.begin(), order.end(), rng);
  for(int i = 0; i < n; i++) broken[i] = 0;
  for(int i = 0; i < k; i++) broken[p[i]] = 1;

  for(int i = 0, pre = -1, j = 59; i < n; i++) {
    if (broken[order[i]] || j < 0) {
      Set(order[i], 0);
      continue;
    }
    bool a = x >> j & 1;
    bool b = i - pre - 1 & 1;
    if (a == b) {
      pre = i;
      j--;
      Set(order[i], 1);
    }
    else Set(order[i], 0);
  }
}
#include "Brunolib.h"
#include<bits/stdc++.h>
using namespace std;

namespace {
mt19937 rng(1);

}

long long Bruno( int n, int a[] ){
  long long x = 0;
  vector<int> order(n);
  for(int i = 0; i < n; i++) order[i] = i;
  shuffle(order.begin(), order.end(), rng);
//  for(int i = 0; i < n; i++) cout << order[i] << " "; cout << endl;
  for(int i = 0, pre = -1, j = 59; i < n && j >= 0; i++) if (a[order[i]]) {
    bool bit = i - pre - 1 & 1;
    if (bit) x |= (1LL << j);
    j--;
    pre = i;
  }
//  cout << "answer :" << x << endl;
  return x;
}

Compilation message

Anna.cpp: In function 'void Anna(int, long long int, int, int*)':
Anna.cpp:23:22: warning: suggest parentheses around '-' in operand of '&' [-Wparentheses]
   23 |     bool b = i - pre - 1 & 1;
      |              ~~~~~~~~^~~

Bruno.cpp: In function 'long long int Bruno(int, int*)':
Bruno.cpp:17:24: warning: suggest parentheses around '-' in operand of '&' [-Wparentheses]
   17 |     bool bit = i - pre - 1 & 1;
      |                ~~~~~~~~^~~
# 결과 실행 시간 메모리 Grader output
1 Partially correct 40 ms 2372 KB Output is partially correct - L* = 30
2 Partially correct 29 ms 2516 KB Output is partially correct - L* = 31
3 Partially correct 37 ms 2396 KB Output is partially correct - L* = 27
4 Partially correct 28 ms 2388 KB Output is partially correct - L* = 30
5 Partially correct 29 ms 2396 KB Output is partially correct - L* = 28
6 Partially correct 33 ms 2308 KB Output is partially correct - L* = 28
7 Partially correct 28 ms 2368 KB Output is partially correct - L* = 34
8 Partially correct 30 ms 2404 KB Output is partially correct - L* = 25
9 Partially correct 29 ms 2492 KB Output is partially correct - L* = 31
10 Partially correct 29 ms 2492 KB Output is partially correct - L* = 32
11 Partially correct 34 ms 2616 KB Output is partially correct - L* = 31
12 Partially correct 30 ms 2692 KB Output is partially correct - L* = 24
13 Partially correct 33 ms 2376 KB Output is partially correct - L* = 22
14 Partially correct 32 ms 2396 KB Output is partially correct - L* = 31
15 Partially correct 36 ms 2460 KB Output is partially correct - L* = 26
16 Partially correct 32 ms 2372 KB Output is partially correct - L* = 32
17 Partially correct 29 ms 2660 KB Output is partially correct - L* = 30
18 Partially correct 29 ms 2372 KB Output is partially correct - L* = 24
19 Partially correct 35 ms 2396 KB Output is partially correct - L* = 28
20 Partially correct 29 ms 2372 KB Output is partially correct - L* = 23
21 Partially correct 33 ms 2488 KB Output is partially correct - L* = 24
22 Partially correct 31 ms 2400 KB Output is partially correct - L* = 30
23 Partially correct 33 ms 2396 KB Output is partially correct - L* = 27
24 Partially correct 34 ms 2436 KB Output is partially correct - L* = 30
25 Partially correct 31 ms 2652 KB Output is partially correct - L* = 32
26 Partially correct 29 ms 2404 KB Output is partially correct - L* = 26
27 Partially correct 40 ms 2396 KB Output is partially correct - L* = 28
28 Partially correct 38 ms 2672 KB Output is partially correct - L* = 25
29 Partially correct 28 ms 2372 KB Output is partially correct - L* = 30
30 Partially correct 29 ms 2396 KB Output is partially correct - L* = 26
31 Partially correct 37 ms 2428 KB Output is partially correct - L* = 30
32 Partially correct 29 ms 2596 KB Output is partially correct - L* = 29
33 Partially correct 29 ms 2492 KB Output is partially correct - L* = 29
34 Partially correct 29 ms 2396 KB Output is partially correct - L* = 27
35 Partially correct 31 ms 2468 KB Output is partially correct - L* = 36
36 Partially correct 28 ms 2396 KB Output is partially correct - L* = 24
37 Partially correct 31 ms 2468 KB Output is partially correct - L* = 32
38 Partially correct 29 ms 2396 KB Output is partially correct - L* = 32
39 Partially correct 38 ms 2456 KB Output is partially correct - L* = 24
40 Partially correct 29 ms 2372 KB Output is partially correct - L* = 26