Submission #977832

# Submission time Handle Problem Language Result Execution time Memory
977832 2024-05-08T11:39:20 Z nguyentunglam Broken Device (JOI17_broken_device) C++17
100 / 100
208 ms 2904 KB
#include "Annalib.h"
#include<bits/stdc++.h>
using namespace std;

namespace {
mt19937 rng(145);

const int m = 120, 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 = 120, 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;
}
# Verdict Execution time Memory Grader output
1 Correct 190 ms 2360 KB Output is correct - L* = 40
2 Correct 193 ms 2392 KB Output is correct - L* = 40
3 Correct 192 ms 2392 KB Output is correct - L* = 40
4 Correct 191 ms 2436 KB Output is correct - L* = 40
5 Correct 208 ms 2516 KB Output is correct - L* = 40
6 Correct 193 ms 2384 KB Output is correct - L* = 40
7 Correct 204 ms 2600 KB Output is correct - L* = 40
8 Correct 191 ms 2448 KB Output is correct - L* = 40
9 Correct 191 ms 2616 KB Output is correct - L* = 40
10 Correct 204 ms 2300 KB Output is correct - L* = 40
11 Correct 194 ms 2296 KB Output is correct - L* = 40
12 Correct 198 ms 2676 KB Output is correct - L* = 40
13 Correct 191 ms 2304 KB Output is correct - L* = 40
14 Correct 199 ms 2484 KB Output is correct - L* = 40
15 Correct 192 ms 2556 KB Output is correct - L* = 40
16 Correct 199 ms 2440 KB Output is correct - L* = 40
17 Correct 196 ms 2512 KB Output is correct - L* = 40
18 Correct 197 ms 2364 KB Output is correct - L* = 40
19 Correct 198 ms 2904 KB Output is correct - L* = 40
20 Correct 193 ms 2380 KB Output is correct - L* = 40
21 Correct 191 ms 2408 KB Output is correct - L* = 40
22 Correct 190 ms 2348 KB Output is correct - L* = 40
23 Correct 195 ms 2488 KB Output is correct - L* = 40
24 Correct 194 ms 2636 KB Output is correct - L* = 40
25 Correct 192 ms 2392 KB Output is correct - L* = 40
26 Correct 200 ms 2380 KB Output is correct - L* = 40
27 Correct 196 ms 2456 KB Output is correct - L* = 40
28 Correct 192 ms 2500 KB Output is correct - L* = 40
29 Correct 200 ms 2516 KB Output is correct - L* = 40
30 Correct 191 ms 2344 KB Output is correct - L* = 40
31 Correct 193 ms 2388 KB Output is correct - L* = 40
32 Correct 191 ms 2312 KB Output is correct - L* = 40
33 Correct 191 ms 2304 KB Output is correct - L* = 40
34 Correct 195 ms 2464 KB Output is correct - L* = 40
35 Correct 195 ms 2384 KB Output is correct - L* = 40
36 Correct 195 ms 2736 KB Output is correct - L* = 40
37 Correct 192 ms 2436 KB Output is correct - L* = 40
38 Correct 191 ms 2504 KB Output is correct - L* = 40
39 Correct 191 ms 2400 KB Output is correct - L* = 40
40 Correct 194 ms 2300 KB Output is correct - L* = 40