답안 #1028816

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1028816 2024-07-20T09:08:06 Z AdamGS Ancient Machine (JOI21_ancient_machine) C++17
99 / 100
49 ms 9156 KB
#include "Anna.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 enc(vector<int>P) {
  vector<ll>ile(51);
  ile[0]=1;
  ile[1]=2;
  for(ll i=2; i<=50; ++i) ile[i]=ile[i-1]+ile[i-2];
  for(int i=0; i<P.size(); i+=50) {
    ll x=0;
    rep(j, 50) if(P[i+j]) x+=ile[50-j-1];
    rep(j, 35) if(x&(1ll<<(ll)j)) Send(1); else Send(0);
  }
}
void Anna(int n, vector<char>T) {
  vector<int>P(n);
  bool ok=false;
  rep(i, n) if(T[i]=='X') {
    ok=true;
    P[i]=1;
    for(int j=i+1; j<n; ++j) {
      if(T[j]=='Z') P[j]=1;
    }
    for(int j=n-1; j; --j) if(P[j-1] && P[j]) P[j-1]=0;
    if(P[i]==0) Send(1); else Send(0);
    break;
  }
  if(!ok) Send(0);
  while(P.size()%50!=0) P.pb(0);
  enc(P);
}
#include "Bruno.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()
vector<int>dec(vector<int>P) {
  vector<int>T;
  vector<ll>ile(51);
  ile[0]=1;
  ile[1]=2;
  for(ll i=2; i<=50; ++i) ile[i]=ile[i-1]+ile[i-2];
  for(int i=1; i<P.size(); i+=35) {
    ll x=0;
    rep(j, 35) if(P[i+j]) x|=1ll<<(ll)j;
    rep(j, 50) {
      if(x>=ile[50-j-1]) {
        x-=ile[50-j-1];
        T.pb(1);
        if(j+1<50) T.pb(0);
        ++j;
      } else T.pb(0);
    }
  }
  rep(i, T.size()) if(T[i]==1) {
    if(P[0]) T[i-1]=1;
    break;
  }
  return T;
}
void Bruno(int n, int m, vector<int>P) {
  vector<int>T=dec(P);
  int x=-1;
  rep(i, n) {
    if(T[i]) {
      x=i;
      break;
    } else Remove(i);
  }
  if(x==-1) return;
  int lst=x;
  for(int i=x+1; i<n; ++i) if(T[i]) {
    for(int j=i-1; j>lst; --j) Remove(j);
    Remove(i);
    lst=i;
  }
  Remove(x);
  for(int i=lst+1; i<n; ++i) Remove(i);
}

Compilation message

Anna.cpp: In function 'void enc(std::vector<int>)':
Anna.cpp:15:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |   for(int i=0; i<P.size(); i+=50) {
      |                ~^~~~~~~~~

Bruno.cpp: In function 'std::vector<int> dec(std::vector<int>)':
Bruno.cpp:16:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |   for(int i=1; i<P.size(); i+=35) {
      |                ~^~~~~~~~~
Bruno.cpp:5:36: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    5 | #define rep(a, b) for(int a = 0; a < (b); ++a)
      |                                    ^
Bruno.cpp:28:3: note: in expansion of macro 'rep'
   28 |   rep(i, T.size()) if(T[i]==1) {
      |   ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 784 KB Output is correct
2 Correct 0 ms 796 KB Output is correct
3 Correct 0 ms 868 KB Output is correct
4 Correct 0 ms 784 KB Output is correct
5 Correct 1 ms 788 KB Output is correct
6 Correct 0 ms 796 KB Output is correct
7 Correct 1 ms 796 KB Output is correct
8 Correct 0 ms 784 KB Output is correct
9 Correct 0 ms 784 KB Output is correct
10 Correct 1 ms 796 KB Output is correct
11 Correct 0 ms 796 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 36 ms 8788 KB Partially correct
2 Partially correct 33 ms 8708 KB Partially correct
3 Partially correct 34 ms 9156 KB Partially correct
4 Partially correct 33 ms 8948 KB Partially correct
5 Partially correct 44 ms 9000 KB Partially correct
6 Partially correct 40 ms 9012 KB Partially correct
7 Partially correct 33 ms 9040 KB Partially correct
8 Partially correct 38 ms 8976 KB Partially correct
9 Partially correct 37 ms 8940 KB Partially correct
10 Partially correct 34 ms 8944 KB Partially correct
11 Partially correct 33 ms 9044 KB Partially correct
12 Partially correct 34 ms 8960 KB Partially correct
13 Partially correct 38 ms 8976 KB Partially correct
14 Partially correct 40 ms 8956 KB Partially correct
15 Partially correct 32 ms 8980 KB Partially correct
16 Partially correct 33 ms 8956 KB Partially correct
17 Partially correct 40 ms 8996 KB Partially correct
18 Partially correct 39 ms 8984 KB Partially correct
19 Partially correct 42 ms 8968 KB Partially correct
20 Partially correct 32 ms 8944 KB Partially correct
21 Partially correct 37 ms 8956 KB Partially correct
22 Partially correct 38 ms 9008 KB Partially correct
23 Partially correct 31 ms 9024 KB Partially correct
24 Partially correct 32 ms 9036 KB Partially correct
25 Partially correct 38 ms 9040 KB Partially correct
26 Partially correct 38 ms 9008 KB Partially correct
27 Partially correct 38 ms 9024 KB Partially correct
28 Partially correct 40 ms 9036 KB Partially correct
29 Partially correct 49 ms 8780 KB Partially correct
30 Partially correct 38 ms 8948 KB Partially correct
31 Partially correct 39 ms 8680 KB Partially correct
32 Partially correct 31 ms 9024 KB Partially correct
33 Partially correct 34 ms 8996 KB Partially correct