답안 #977827

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
977827 2024-05-08T11:37:05 Z nguyentunglam Broken Device (JOI17_broken_device) C++17
100 / 100
262 ms 2996 KB
#include "Annalib.h"
#include<bits/stdc++.h>
using namespace std;

namespace {
mt19937 rng(145);

const int m = 150, T = 60;

bitset<m + 1> a[T];

long long rnd(long long l, long long r) {
  return l + rng() % (r - l + 1);
}
}


void Anna( int n, long long x, int k, int P[] ){
  vector<long long> b(m);
  for(int i = 0; i < T; i++) {
    for(int j = 0; j < m; j++) a[i][j] = rnd(0, 1);
    a[i][m] = x >> i & 1;
  }

  vector<bool> broken(n, 0);

  for(int i = 0; i < k; i++) broken[P[i]] = 1;

  for(int i = 0; i < m; i++) if (broken[i]) {
    for(int j = 0; j < T; j++) a[j][i] = 0;
  }

  for(int i = 0; i < m; i++) {
    for(int j = 0; j < T; j++) if (a[j][i]) b[i] |= (1 << j);
  }

//  for(int i = 0; i < m; i++) cout << b[i] << endl;

  vector<int> pos(T, -1);

  for(int col = 0, row = 0; col < m && row < T; col++) {
    for(int i = row; i < T; i++) if (a[i][col]) {
      swap(a[i], a[row]);
      break;
    }
    if (a[row][col] == 0) continue;
    pos[row] = col;
    for(int i = 0; i < T; i++) if (i != row && a[i][col]) a[i] ^= a[row];
    row++;
  }

//  for(int i = 0; i < T; i++) cout << a[i] << endl;

  vector<int> ans(m, 0);


  for(int i = 0; i < T; i++) {
    int x = pos[i];
    ans[x] = a[i][m];
  }
  int Xor = 0;
  for(int i = 0; i < m; i++) if (ans[i]) Xor ^= b[i];
//  cout << Xor << endl;

  for(int i = 0; i < m; i++) Set(i, ans[i]);
  for(int i = m; i < n; i++) Set(i, 0);
}
#include "Brunolib.h"
#include<bits/stdc++.h>
using namespace std;

namespace {
mt19937 rng(145);

const int m = 150, T = 60;

bitset<m + 1> a[60];

long long rnd(long long l, long long r) {
  return l + rng() % (r - l + 1);
}

}


long long Bruno( int N, int A[] ){
//  vector<long long> b(m);
  for(int i = 0; i < T; i++) {
    for(int j = 0; j < m; j++) a[i][j] = rnd(0, 1);
  }
//
//  for(int i = 0; i < m; i++) {
//    for(int j = 0; j < T; j++) if (a[j][i]) b[i] |= (1 << j);
//  }

  long long ans = 0;

  for(int i = 0; i < T; i++) {
    int sum = 0;
    for(int j = 0; j < m; j++) if (A[j]) sum ^= a[i][j];
    if (sum) ans |= (1LL << i);
  }

//  cout << ans << endl;

  return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 248 ms 2808 KB Output is correct - L* = 40
2 Correct 227 ms 2684 KB Output is correct - L* = 40
3 Correct 244 ms 2696 KB Output is correct - L* = 40
4 Correct 228 ms 2820 KB Output is correct - L* = 40
5 Correct 235 ms 2840 KB Output is correct - L* = 40
6 Correct 230 ms 2696 KB Output is correct - L* = 40
7 Correct 228 ms 2940 KB Output is correct - L* = 40
8 Correct 228 ms 2752 KB Output is correct - L* = 40
9 Correct 232 ms 2692 KB Output is correct - L* = 40
10 Correct 232 ms 2864 KB Output is correct - L* = 40
11 Correct 231 ms 2780 KB Output is correct - L* = 40
12 Correct 228 ms 2556 KB Output is correct - L* = 40
13 Correct 230 ms 2604 KB Output is correct - L* = 40
14 Correct 229 ms 2632 KB Output is correct - L* = 40
15 Correct 240 ms 2792 KB Output is correct - L* = 40
16 Correct 228 ms 2796 KB Output is correct - L* = 40
17 Correct 229 ms 2672 KB Output is correct - L* = 40
18 Correct 229 ms 2672 KB Output is correct - L* = 40
19 Correct 229 ms 2616 KB Output is correct - L* = 40
20 Correct 231 ms 2616 KB Output is correct - L* = 40
21 Correct 228 ms 2728 KB Output is correct - L* = 40
22 Correct 228 ms 2996 KB Output is correct - L* = 40
23 Correct 228 ms 2816 KB Output is correct - L* = 40
24 Correct 241 ms 2616 KB Output is correct - L* = 40
25 Correct 228 ms 2848 KB Output is correct - L* = 40
26 Correct 255 ms 2932 KB Output is correct - L* = 40
27 Correct 240 ms 2768 KB Output is correct - L* = 40
28 Correct 238 ms 2808 KB Output is correct - L* = 40
29 Correct 262 ms 2700 KB Output is correct - L* = 40
30 Correct 239 ms 2748 KB Output is correct - L* = 40
31 Correct 254 ms 2544 KB Output is correct - L* = 40
32 Correct 236 ms 2652 KB Output is correct - L* = 40
33 Correct 244 ms 2948 KB Output is correct - L* = 40
34 Correct 231 ms 2632 KB Output is correct - L* = 40
35 Correct 234 ms 2560 KB Output is correct - L* = 40
36 Correct 236 ms 2756 KB Output is correct - L* = 40
37 Correct 233 ms 2704 KB Output is correct - L* = 40
38 Correct 258 ms 2856 KB Output is correct - L* = 40
39 Correct 235 ms 2676 KB Output is correct - L* = 40
40 Correct 231 ms 2636 KB Output is correct - L* = 40