Submission #1062456

#TimeUsernameProblemLanguageResultExecution timeMemory
1062456sleepntsheepFlights (JOI22_flights)C++17
Compilation error
0 ms0 KiB
#include "Ali.h"
#include <string>
#include <algorithm>
#include <array>
#include <cassert>
#include <algorithm>
#include <vector>
using namespace std;
using ll = long long;

constexpr int BASE=1e9,D=99;
struct bigint{
  array<ll,D>v{};
  bigint(ll x){ v[0]=x;}
  bigint() {}
  int cmpr(const bigint &o)const { for(int i=D-1;i>=0;--i)if(v[i]!=o.v[i])return v[i]<o.v[i]?-1:1; return 0; };
  const bigint& operator+=(const bigint&o){
    ll carry=0;
    for(int i=0;i<D;++i){
      v[i]=(carry+o.v[i]+v[i]);
      carry=v[i]/BASE;
      v[i]%=BASE;
    }
    return *this;
  }
  const bigint& operator-=(const bigint&o){
    for(int i=0;i<D;++i){
      v[i]=(v[i]-o.v[i]);
      if(v[i]<0)v[i]+=BASE,v[i+1]--;
    }
    return*this;
  }
  const bigint& operator*=(ll x){
    ll carry=0;
    for(int i=0;i<D;++i){
      v[i]=(v[i]*x+carry);
      carry=v[i]/BASE;
      v[i]%=BASE;
    }
    return *this;
  }
  friend bigint operator+(bigint&lhs,bigint&rhs){return lhs+=rhs;}
  friend bigint operator-(bigint&lhs,bigint&rhs){return lhs-=rhs;}
  friend bigint operator*(bigint&lhs,ll rhs){return lhs*=rhs;}
  bool operator<(const bigint &o)const{return cmpr(o)==-1;}
  bool operator>(const bigint &o)const{return cmpr(o)==1;}
  bool operator>=(const bigint &o)const{return cmpr(o)>=0;}
  bool operator<=(const bigint &o)const{return cmpr(o)<=0;}
  bool operator==(const bigint &o)const{return cmpr(o)==0;}
};

namespace {
  const int N=30000;
  std::vector<int> g[N];
  int hld[N],par[N],sz[N],dep[N];
  void dfs(int u,int p){ dep[u]=dep[par[u]=p]+1;int best=0; sz[u]=1;for(auto &v:g[u])if(v-p){ dfs(v,u),sz[u]+=sz[v]; if(sz[v]>best)swap(v,g[u][0]),best=sz[v]; } }
  void efs(int u){ for(auto v:g[u])if(v-par[u]) hld[v]=(v==g[u][0])?hld[u]:v,efs(v); }
  int lca(int u,int v){ while(hld[u]-hld[v]){ if(dep[hld[u]]<dep[hld[v]])swap(u,v); u=par[hld[u]]; } return dep[u]<dep[v]?u:v; }
  int dist(int u,int v){return dep[u]+dep[v]-2*dep[lca(u,v)];}
  ll read(string&s,int i,int b=14){ int z=0; for(int j=0;j<b;++j)z|=((s[i+j]-'0'))<<j; return z; }

  int nn;
  ll valid_enc(ll enc){ return enc/10000<nn and enc%10000<nn; }
  ll XX(ll enc){return enc/10000;}
  ll YY(ll enc){return enc%10000;}

  const int B2=1210;
  bigint pw2[B2+1];
  bigint npow[99];int inited;
  string to_string(bigint &b){ string T; for(int i=B2-1;i>=0;--i) if(b<pw2[i]) T+='0'; else T+='1',b-=pw2[i]; reverse(T.begin(),T.end());return T; }
  void init(){ if(inited)return; inited=1; npow[0]=1; for(int i=1;i<99;++i) npow[i]=npow[i-1]*10000;
    pw2[0]=1;for(int i=1;i<=B2;++i)pw2[i]=pw2[i-1]*2; }
}

void Init(int N, std::vector<int> U, std::vector<int> V) {
  init();
  ::nn = N;
  for(int i=0;i<N;++i)g[i].clear(),hld[i]=0,par[i]=0,sz[i]=0,dep[i]=0;
  for(int i=0;i+1<N;++i)g[U[i]].push_back(V[i]),g[V[i]].push_back(U[i]);
  for(int i=0;i<N;++i)SetID(i,i);
  dfs(0,0);
  hld[0]=0;efs(0);
}

#include<stdio.h>
std::string SendA(std::string S) {
  init();

  ll enc=read(S,0,20);
  vector<int>dis;
  for(ll j=0;j<(1<<7);++j){
    ll enc2 = (enc&((1<<20)-1)) | (j<<20);
    if(valid_enc(enc2))dis.push_back(dist(XX(enc2),YY(enc2)));
  }

  bigint b;
  for(int i=0;i<(int)dis.size();++i)b+=npow[i]*dis[i];

  return to_string(b);
}

#include "Ali.h"
#include <string>
#include <algorithm>
#include <array>
#include <cassert>
#include <algorithm>
#include <vector>
using namespace std;
using ll = long long;

constexpr int BASE=1e9,D=150;
struct bigint{
  array<ll,D>v{};
  bigint(ll x){ v[0]=x;}
  bigint() {}
  int cmpr(const bigint &o)const { for(int i=D-1;i>=0;--i)if(v[i]!=o.v[i])return v[i]<o.v[i]?-1:1; return 0; };
  const bigint& operator+=(const bigint&o){
    ll carry=0;
    for(int i=0;i<D;++i){
      v[i]=(carry+o.v[i]+v[i]);
      carry=v[i]/BASE;
      v[i]%=BASE;
    }
    return *this;
  }
  const bigint& operator-=(const bigint&o){
    for(int i=0;i<D;++i){
      v[i]=(v[i]-o.v[i]);
      if(v[i]<0)v[i]+=BASE,v[i+1]--;
    }
    return*this;
  }
  const bigint& operator*=(ll x){
    ll carry=0;
    for(int i=0;i<D;++i){
      v[i]=(v[i]*x+carry);
      carry=v[i]/BASE;
      v[i]%=BASE;
    }
    return *this;
  }
  friend bigint operator+(bigint&lhs,bigint&rhs){return lhs+=rhs;}
  friend bigint operator-(bigint&lhs,bigint&rhs){return lhs-=rhs;}
  friend bigint operator*(bigint&lhs,ll rhs){return lhs*=rhs;}
  bool operator<(const bigint &o)const{return cmpr(o)==-1;}
  bool operator>(const bigint &o)const{return cmpr(o)==1;}
  bool operator>=(const bigint &o)const{return cmpr(o)>=0;}
  bool operator<=(const bigint &o)const{return cmpr(o)<=0;}
  bool operator==(const bigint &o)const{return cmpr(o)==0;}
};

namespace {
  const int N=30000;
  std::vector<int> g[N];
  int hld[N],par[N],sz[N],dep[N];
  void dfs(int u,int p){ dep[u]=dep[par[u]=p]+1;int best=0; sz[u]=1;for(auto &v:g[u])if(v-p){ dfs(v,u),sz[u]+=sz[v]; if(sz[v]>best)swap(v,g[u][0]),best=sz[v]; } }
  void efs(int u){ for(auto v:g[u])if(v-par[u]) hld[v]=(v==g[u][0])?hld[u]:v,efs(v); }
  int lca(int u,int v){ while(hld[u]-hld[v]){ if(dep[hld[u]]<dep[hld[v]])swap(u,v); u=par[hld[u]]; } return dep[u]<dep[v]?u:v; }
  int dist(int u,int v){return dep[u]+dep[v]-2*dep[lca(u,v)];}
  ll read(string&s,int i,int b=14){ int z=0; for(int j=0;j<b;++j)z|=((s[i+j]-'0'))<<j; return z; }

  int nn;
  ll valid_enc(ll enc){ return enc/10000<nn and enc%10000<nn; }
  ll XX(ll enc){return enc/10000;}
  ll YY(ll enc){return enc%10000;}

  const int B2=1250;
  bigint pw2[B2+1];
  bigint npow[99];int inited;
  string to_string(bigint &b){ string T; for(int i=B2-1;i>=0;--i) if(b<pw2[i]) T+='0'; else T+='1',b-=pw2[i]; reverse(T.begin(),T.end());return T; }
  void init(){ if(inited)return; inited=1; npow[0]=1; for(int i=1;i<99;++i) npow[i]=npow[i-1]*10000;
    pw2[0]=1;for(int i=1;i<=B2;++i)pw2[i]=pw2[i-1]*2; }
}

void Init(int N, std::vector<int> U, std::vector<int> V) {
  init();
  ::nn = N;
  for(int i=0;i<N;++i)g[i].clear(),hld[i]=0,par[i]=0,sz[i]=0,dep[i]=0;
  for(int i=0;i+1<N;++i)g[U[i]].push_back(V[i]),g[V[i]].push_back(U[i]);
  for(int i=0;i<N;++i)SetID(i,i);
  dfs(0,0);
  hld[0]=0;efs(0);
}

#include<stdio.h>
std::string SendA(std::string S) {
  init();

  ll enc=read(S,0,20);
  vector<int>dis;
  for(ll j=0;j<(1<<7);++j){
    ll enc2 = (enc&((1<<20)-1)) | (j<<20);
    if(valid_enc(enc2))dis.push_back(dist(XX(enc2),YY(enc2)));
  }

  bigint b;
  for(int i=0;i<(int)dis.size();++i)b+=npow[i]*dis[i];

  return to_string(b);
}

Compilation message (stderr)

grader_ali.cpp:10:8: warning: '{anonymous}::_randmem' defined but not used [-Wunused-variable]
   10 |   char _randmem[12379];
      |        ^~~~~~~~

/usr/bin/ld: /tmp/cctXflZ3.o: in function `Init(int, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)':
Benjamin.cpp:(.text+0x4b0): undefined reference to `SetID(int, int)'
/usr/bin/ld: Benjamin.cpp:(.text+0x4e5): undefined reference to `SetID(int, int)'
/usr/bin/ld: /tmp/cc60icP7.o: in function `main':
grader_benjamin.cpp:(.text.startup+0x19a): undefined reference to `Answer(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
/usr/bin/ld: grader_benjamin.cpp:(.text.startup+0x24f): undefined reference to `SendB[abi:cxx11](int, int, int)'
collect2: error: ld returned 1 exit status