Submission #999133

# Submission time Handle Problem Language Result Execution time Memory
999133 2024-06-15T07:12:08 Z AdamGS Broken Device (JOI17_broken_device) C++17
100 / 100
37 ms 2888 KB
#include "Annalib.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
void Anna(int n, ll x, int k, int P[]) {
  vector<ll>A={-1, 0, 1, 2, 0, 1, 1, 3}, B={-1, 4, 2, 4, 2, 2, 4, 4};
  vector<int>czy(n), T(n);
  rep(i, k) czy[P[i]]=1;
  ll akt=0;
  for(int i=0; i<n; i+=3) {
    int s=czy[i]+czy[i+1]+czy[i+2];
    if(s>=2) continue;
    ll a=x%4;
    bool ok=false;
    rep(j, 8) if(A[j]==a && B[j]==4) {
      bool ok2=true;
      rep(l, 3) if(czy[i+l] && (j&(1<<l))) ok2=false;
      if(!ok2) continue;
      rep(l, 3) if(j&(1<<l)) T[i+l]=1;
      ok=true;
      x/=4;
      break;
    }
    if(ok) continue;
    a=x%2;
    rep(j, 8) if(A[j]==a && B[j]==2) {
      bool ok2=true;
      rep(l, 3) if(czy[i+l] && (j&(1<<l))) ok2=false;
      if(!ok2) continue;
      rep(l, 3) if(j&(1<<l)) T[i+l]=1;
      ok=true;
      x/=2;
      break;
    }
  }
  rep(i, n) Set(i, T[i]);
}
#include "Brunolib.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
ll Bruno(int n, int T[]) {
  vector<ll>A={-1, 0, 1, 2, 0, 1, 1, 3}, B={-1, 4, 2, 4, 2, 2, 4, 4};  
  ll x=0, p=1;
  for(int i=0; i<n; i+=3) {
    if(T[i]+T[i+1]+T[i+2]==0) continue;
    ll c=T[i]+2*T[i+1]+4*T[i+2];
    x+=p*A[c];
    p*=B[c];
  }
  return x;
}

Compilation message

Anna.cpp: In function 'void Anna(int, ll, int, int*)':
Anna.cpp:14:6: warning: unused variable 'akt' [-Wunused-variable]
   14 |   ll akt=0;
      |      ^~~
# Verdict Execution time Memory Grader output
1 Correct 23 ms 2780 KB Output is correct - L* = 40
2 Correct 22 ms 2784 KB Output is correct - L* = 40
3 Correct 20 ms 2888 KB Output is correct - L* = 40
4 Correct 24 ms 2684 KB Output is correct - L* = 40
5 Correct 22 ms 2784 KB Output is correct - L* = 40
6 Correct 22 ms 2776 KB Output is correct - L* = 40
7 Correct 20 ms 2864 KB Output is correct - L* = 40
8 Correct 20 ms 2784 KB Output is correct - L* = 40
9 Correct 20 ms 2776 KB Output is correct - L* = 40
10 Correct 22 ms 2752 KB Output is correct - L* = 40
11 Correct 37 ms 2688 KB Output is correct - L* = 40
12 Correct 20 ms 2776 KB Output is correct - L* = 40
13 Correct 20 ms 2772 KB Output is correct - L* = 40
14 Correct 20 ms 2776 KB Output is correct - L* = 40
15 Correct 22 ms 2776 KB Output is correct - L* = 40
16 Correct 24 ms 2816 KB Output is correct - L* = 40
17 Correct 22 ms 2772 KB Output is correct - L* = 40
18 Correct 20 ms 2804 KB Output is correct - L* = 40
19 Correct 23 ms 2872 KB Output is correct - L* = 40
20 Correct 24 ms 2772 KB Output is correct - L* = 40
21 Correct 24 ms 2860 KB Output is correct - L* = 40
22 Correct 22 ms 2768 KB Output is correct - L* = 40
23 Correct 20 ms 2764 KB Output is correct - L* = 40
24 Correct 22 ms 2824 KB Output is correct - L* = 40
25 Correct 28 ms 2764 KB Output is correct - L* = 40
26 Correct 28 ms 2772 KB Output is correct - L* = 40
27 Correct 22 ms 2772 KB Output is correct - L* = 40
28 Correct 22 ms 2840 KB Output is correct - L* = 40
29 Correct 22 ms 2760 KB Output is correct - L* = 40
30 Correct 20 ms 2872 KB Output is correct - L* = 40
31 Correct 20 ms 2748 KB Output is correct - L* = 40
32 Correct 24 ms 2784 KB Output is correct - L* = 40
33 Correct 20 ms 2780 KB Output is correct - L* = 40
34 Correct 23 ms 2776 KB Output is correct - L* = 40
35 Correct 22 ms 2788 KB Output is correct - L* = 40
36 Correct 22 ms 2752 KB Output is correct - L* = 40
37 Correct 20 ms 2780 KB Output is correct - L* = 40
38 Correct 20 ms 2768 KB Output is correct - L* = 40
39 Correct 20 ms 2872 KB Output is correct - L* = 40
40 Correct 23 ms 2752 KB Output is correct - L* = 40