Submission #997047

# Submission time Handle Problem Language Result Execution time Memory
997047 2024-06-11T16:16:17 Z huutuan Magic Show (APIO24_show) C++17
0 / 100
4 ms 24888 KB
#include <vector>
#include "Alice.h"

// you may define some global variables, but it does not work if you try to transfer any information from function Alice() to function Bob() through these variables.
// you had better not use the same global variables in function Alice() and in function Bob().

#include <bits/stdc++.h>

using namespace std;

#define int long long

namespace Alice_solver{
   int c[100][100];
   vector<int> encode(int x){
      vector<int> ans(64);
      for (int i=0, rem=32; i<64; ++i){
         if (x>=c[64-i-1][rem-1]){
            x-=c[64-i-1][rem-1];
            --rem;
            ans[i]=1;
         }
      }
      return ans;
   }
   int decode(vector<int> v){
      int ans=0;
      for (int i=0, rem=32; i<64; ++i){
         if (v[i]){
            ans+=c[64-i-1][rem-1];
            --rem;
         }
      }
      return ans;
   }
   int mp[5000], rmp[5000];
   mt19937 rng(69420);
   void precalc(){
      for (int i=0; i<=64; ++i) c[i][0]=c[i][i]=1;
      for (int i=1; i<=64; ++i){
         for (int j=1; j<i; ++j) c[i][j]=c[i-1][j-1]+c[i-1][j];
      }
      iota(mp, mp+4950, 0);
      shuffle(mp, mp+4950, rng);
      for (int i=0; i<4950; ++i) rmp[mp[i]]=i;
   }
   vector<pair<int32_t, int32_t>> solve(){
      precalc();
      long long x=setN(4950);
      vector<int> v=encode(x);
      vector<pair<int32_t, int32_t>> ans;
      for (int i=0; i<4950; i+=66){
         for (int j=0; j<64; ++j){
            if (v[j]){
               ans.emplace_back(i+j, i+65);
            }else{
               ans.emplace_back(i+j, i+64);
            }
         }
         ans.emplace_back(i+64, i+65);
         if (i) ans.emplace_back(i+64, i-1);
      }
      for (auto &i:ans) i.first=mp[i.first]+1, i.second=mp[i.second]+1;
      return ans;
   }
}

vector<pair<int32_t,int32_t>> Alice(){
   // add your code here
   
   // change below into your code
   return Alice_solver::solve();
}
#include <vector>
#include "Bob.h"

// you may define some global variables, but it does not work if you try to transfer any information from function Alice() to function Bob() through these variables.
// you had better not use the same global variables in function Alice() and in function Bob().

#include <bits/stdc++.h>

using namespace std;

#define int long long

namespace Bob_solver{
   int c[100][100];
   vector<int> encode(int x){
      vector<int> ans(64);
      for (int i=0, rem=32; i<64; ++i){
         if (x>=c[64-i-1][rem-1]){
            x-=c[64-i-1][rem-1];
            --rem;
            ans[i]=1;
         }
      }
      return ans;
   }
   int decode(vector<int> v){
      int ans=0;
      for (int i=0, rem=32; i<64; ++i){
         if (v[i]){
            ans+=c[64-i-1][rem-1];
            --rem;
         }
      }
      return ans;
   }
   int mp[5000], rmp[5000];
   mt19937 rng(69420);
   void precalc(){
      for (int i=0; i<=64; ++i) c[i][0]=c[i][i]=1;
      for (int i=1; i<=64; ++i){
         for (int j=1; j<i; ++j) c[i][j]=c[i-1][j-1]+c[i-1][j];
      }
      iota(mp, mp+4950, 0);
      shuffle(mp, mp+4950, rng);
      for (int i=0; i<4950; ++i) rmp[mp[i]]=i;
   }
   bool adj[5000][5000];
   int solve(vector<pair<int32_t, int32_t>> edge){
      precalc();
      for (auto &i:edge) i.first=rmp[i.first-1], i.second=rmp[i.second-1], adj[i.first][i.second]=adj[i.second][i.first]=1;
      vector<int> v(64);
      for (int i=0; i<4950; i+=66){
         for (int j=0; j<64; ++j){
            if (adj[i+j][i+65]) v[j]=1;
         }
      }
      return decode(v);
   }
}

long long Bob(vector<pair<int32_t,int32_t>> V){
   // add your code here
   
   // return 3; // change this into your code
   return Bob_solver::solve(V);
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 24888 KB Correct.
2 Incorrect 4 ms 24376 KB Incorrect answer.
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 24888 KB Correct.
2 Incorrect 4 ms 24376 KB Incorrect answer.
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 24888 KB Correct.
2 Incorrect 4 ms 24376 KB Incorrect answer.
3 Halted 0 ms 0 KB -