답안 #927813

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
927813 2024-02-15T11:02:03 Z huutuan Broken Device (JOI17_broken_device) C++14
100 / 100
38 ms 3028 KB
#include "Annalib.h"

#include<bits/stdc++.h>

using namespace std;

static int broken[150];
static int ans[150];
static mt19937 rng(69420);

void Anna(int n, long long x, int k, int p[]){
   // int add=rng()%177013;
   // x+=add;
   vector<int> order;
   for (int i=0; i<n; ++i) order.push_back(i);
   shuffle(order.begin(), order.end(), rng);
   memset(broken, 0, sizeof broken);
   memset(ans, 0, sizeof ans);
   for (int i=0; i<k; ++i) broken[p[i]]=1;
   for (int i=0; i<n; i+=2){
      if (broken[order[i]] && broken[order[i+1]]) continue;
      if (broken[order[i]]){
         if (x%3==0){
            ans[order[i]]=0, ans[order[i+1]]=1;
            x/=3;
            continue;
         }
      }
      if (broken[order[i+1]]){
         if (x%3==1){
            ans[order[i]]=1, ans[order[i+1]]=0;
            x/=3;
            continue;
         }
      }
      if (!broken[order[i]] && !broken[order[i+1]]){
         if (x%3==0) ans[order[i]]=0, ans[order[i+1]]=1;
         else if (x%3==1) ans[order[i]]=1, ans[order[i+1]]=0;
         else ans[order[i]]=1, ans[order[i+1]]=1;
         x/=3;
      }
   }
   for (int i=0; i<n; ++i) Set(i, ans[i]);
}
#include "Brunolib.h"

#include<bits/stdc++.h>

using namespace std;

static mt19937 rng(69420);

long long Bruno(int n, int a[]){
   // long long add=rng()%177013;
   vector<int> order;
   for (int i=0; i<n; ++i) order.push_back(i);
   shuffle(order.begin(), order.end(), rng);
   long long ans=0;
   long long pw=1;
   for (int i=0; i<n; i+=2){
      if (a[order[i]] || a[order[i+1]]){
         ans+=a[order[i]]*pw*(a[order[i+1]]+1);
         pw*=3;
         if (pw>(long long)1e18) break;
      }
   }
   return ans;
   // return ans-add;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 38 ms 3000 KB Output is correct - L* = 40
2 Correct 29 ms 2880 KB Output is correct - L* = 40
3 Correct 29 ms 2780 KB Output is correct - L* = 40
4 Correct 30 ms 2772 KB Output is correct - L* = 40
5 Correct 29 ms 2876 KB Output is correct - L* = 40
6 Correct 29 ms 2776 KB Output is correct - L* = 40
7 Correct 29 ms 2812 KB Output is correct - L* = 40
8 Correct 31 ms 2664 KB Output is correct - L* = 40
9 Correct 32 ms 2752 KB Output is correct - L* = 40
10 Correct 30 ms 2876 KB Output is correct - L* = 40
11 Correct 30 ms 2776 KB Output is correct - L* = 40
12 Correct 31 ms 2580 KB Output is correct - L* = 40
13 Correct 30 ms 2860 KB Output is correct - L* = 40
14 Correct 32 ms 3028 KB Output is correct - L* = 40
15 Correct 29 ms 2852 KB Output is correct - L* = 40
16 Correct 32 ms 2848 KB Output is correct - L* = 40
17 Correct 30 ms 2776 KB Output is correct - L* = 40
18 Correct 29 ms 2888 KB Output is correct - L* = 40
19 Correct 29 ms 2780 KB Output is correct - L* = 40
20 Correct 30 ms 2772 KB Output is correct - L* = 40
21 Correct 30 ms 2792 KB Output is correct - L* = 40
22 Correct 29 ms 2776 KB Output is correct - L* = 40
23 Correct 28 ms 2872 KB Output is correct - L* = 40
24 Correct 29 ms 2776 KB Output is correct - L* = 40
25 Correct 28 ms 2884 KB Output is correct - L* = 40
26 Correct 28 ms 2776 KB Output is correct - L* = 40
27 Correct 34 ms 2896 KB Output is correct - L* = 40
28 Correct 30 ms 2816 KB Output is correct - L* = 40
29 Correct 29 ms 2704 KB Output is correct - L* = 40
30 Correct 30 ms 2780 KB Output is correct - L* = 40
31 Correct 28 ms 2756 KB Output is correct - L* = 40
32 Correct 28 ms 2856 KB Output is correct - L* = 40
33 Correct 28 ms 2668 KB Output is correct - L* = 40
34 Correct 31 ms 2796 KB Output is correct - L* = 40
35 Correct 33 ms 2800 KB Output is correct - L* = 40
36 Correct 28 ms 2776 KB Output is correct - L* = 40
37 Correct 30 ms 2776 KB Output is correct - L* = 40
38 Correct 28 ms 2824 KB Output is correct - L* = 40
39 Correct 30 ms 2764 KB Output is correct - L* = 40
40 Correct 29 ms 2772 KB Output is correct - L* = 40