답안 #991276

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
991276 2024-06-01T17:23:42 Z abczz Broken Device (JOI17_broken_device) C++14
100 / 100
31 ms 2944 KB
#include "Annalib.h"
#include <iostream>
#include <random>
#include <vector>
#include <algorithm>
#define ll long long
 
using namespace std;
 
void Anna( int N, long long X, int K, int P[] ){
  mt19937_64 mt(69);
  ll perm[150];
  for (int i=0; i<N; ++i) {
    perm[i] = i;
  }
  shuffle(perm, perm+N, mt);
  bool B[150], F[150];
  for (int i=0; i<N; ++i) B[i] = F[i] = 0;
  for (int i=0; i<K; ++i) B[P[i]] = 1;
  for (int i=0; i<N; i+=2) {
    ll cur = X % 3;
    if (B[perm[i]] && B[perm[i+1]]) continue;
    else if (B[perm[i]] && (cur == 1 || cur == 2)) continue;
    else if (B[perm[i+1]] && (!cur || cur == 2)) continue;
    X /= 3;
    if (!cur) F[perm[i+1]] = 1;
    else if (cur == 1) F[perm[i]] = 1;
    else F[perm[i]] = F[perm[i+1]] = 1;
    if (!X) break;
  }
  for (int i=0; i<N; ++i) {
    Set(i, F[i]);
  }
}
#include "Brunolib.h"
#include <iostream>
#include <vector>
#include <random>
#include <algorithm>
#define ll long long
 
using namespace std;
 
long long Bruno( int N, int A[] ){
  mt19937_64 mt(69);
  ll x = 0, s = 1;
  ll perm[150];
  for (int i=0; i<N; ++i) {
    perm[i] = i;
  }
  shuffle(perm, perm+N, mt);
  for (int i=0; i<N; i+=2) {
    if (A[perm[i]] && A[perm[i+1]]) {
      x += s * 2;
      s *= 3;
    }
    else if (A[perm[i]]) {
      x += s;
      s *= 3;
    }
    else if (A[perm[i+1]]) {
      s *= 3;
    }
  }
  return x;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 2776 KB Output is correct - L* = 40
2 Correct 28 ms 2696 KB Output is correct - L* = 40
3 Correct 27 ms 2748 KB Output is correct - L* = 40
4 Correct 23 ms 2656 KB Output is correct - L* = 40
5 Correct 23 ms 2776 KB Output is correct - L* = 40
6 Correct 31 ms 2856 KB Output is correct - L* = 40
7 Correct 23 ms 2772 KB Output is correct - L* = 40
8 Correct 24 ms 2752 KB Output is correct - L* = 40
9 Correct 25 ms 2752 KB Output is correct - L* = 40
10 Correct 27 ms 2944 KB Output is correct - L* = 40
11 Correct 24 ms 2816 KB Output is correct - L* = 40
12 Correct 23 ms 2768 KB Output is correct - L* = 40
13 Correct 23 ms 2788 KB Output is correct - L* = 40
14 Correct 24 ms 2680 KB Output is correct - L* = 40
15 Correct 27 ms 2772 KB Output is correct - L* = 40
16 Correct 26 ms 2748 KB Output is correct - L* = 40
17 Correct 23 ms 2772 KB Output is correct - L* = 40
18 Correct 24 ms 2772 KB Output is correct - L* = 40
19 Correct 24 ms 2772 KB Output is correct - L* = 40
20 Correct 24 ms 2884 KB Output is correct - L* = 40
21 Correct 24 ms 2748 KB Output is correct - L* = 40
22 Correct 24 ms 2780 KB Output is correct - L* = 40
23 Correct 23 ms 2860 KB Output is correct - L* = 40
24 Correct 25 ms 2672 KB Output is correct - L* = 40
25 Correct 26 ms 2752 KB Output is correct - L* = 40
26 Correct 24 ms 2720 KB Output is correct - L* = 40
27 Correct 24 ms 2764 KB Output is correct - L* = 40
28 Correct 24 ms 2856 KB Output is correct - L* = 40
29 Correct 23 ms 2852 KB Output is correct - L* = 40
30 Correct 23 ms 2748 KB Output is correct - L* = 40
31 Correct 23 ms 2724 KB Output is correct - L* = 40
32 Correct 23 ms 2776 KB Output is correct - L* = 40
33 Correct 23 ms 2748 KB Output is correct - L* = 40
34 Correct 23 ms 2848 KB Output is correct - L* = 40
35 Correct 24 ms 2776 KB Output is correct - L* = 40
36 Correct 24 ms 2772 KB Output is correct - L* = 40
37 Correct 24 ms 2776 KB Output is correct - L* = 40
38 Correct 23 ms 2772 KB Output is correct - L* = 40
39 Correct 27 ms 2780 KB Output is correct - L* = 40
40 Correct 24 ms 2736 KB Output is correct - L* = 40