# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1012461 | Unforgettablepl | Ancient Machine (JOI21_ancient_machine) | C++17 | 37 ms | 9112 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "Anna.h"
#include <vector>
#include <bits/stdc++.h>
using namespace std;
namespace {
vector<int> fib(43);
void genFib(){
fib[1] = 1;
for(int i=2;i<43;i++)fib[i]=fib[i-1]+fib[i-2];
}
void blockp(vector<int> block){
int ans = 0;
for(int i=0;i<block.size();i++){
if(block[i])ans+=fib[block.size()-i+1];
}
for(int bit=0;bit<28;bit++)Send(min(1,ans&(1<<bit)));
}
void process(vector<int> arr){
genFib();
for(int blocks=0;blocks<2500;blocks++){
vector<int> curr;
for(int i=0;i<40;i++)curr.emplace_back(arr[blocks*40+i]);
blockp(curr);
}
}
}
void Anna(int N, std::vector<char> S) {
bool foundX = false;
S.emplace_back('$');
vector<int> bits;
for(int i=0;i<N;i++){
if(S[i]=='X'){
if(foundX)bits.emplace_back(0);
else {
foundX = true;
bits.emplace_back(1);
}
} else if(S[i]=='Y'){
bits.emplace_back(0);
} else if(S[i]=='Z'){
if(!foundX or S[i+1]=='Z')bits.emplace_back(0);
else bits.emplace_back(1);
}
}
while(bits.size()<100000)bits.emplace_back(0);
process(bits);
}
#include "Bruno.h"
#include <vector>
#include <bits/stdc++.h>
using namespace std;
namespace {
vector<int> fib(43);
void genFib(){
fib[1] = 1;
for(int i=2;i<43;i++)fib[i]=fib[i-1]+fib[i-2];
}
vector<int> blockp(int tar){
vector<int> ans = {0};
for(int i=0;i<40;i++){
if(ans.back()==0 and fib[40-i+1]<=tar){
ans.emplace_back(1);
tar-=fib[40-i+1];
} else ans.emplace_back(0);
}
ans.erase(ans.begin());
return ans;
}
vector<int> process(vector<int> arr){
genFib();
vector<int> res;
for(int block=0;block<2500;block++){
int curr = 0;
for(int i=0;i<28;i++)if(arr[block*28+i])curr|=(1<<i);
auto ans = blockp(curr);
for(int&i:ans)res.emplace_back(i);
}
return res;
}
} // namespace
void Bruno(int N, int L, std::vector<int> A) {
vector<int> PR;
// Process A into PR
PR = process(A);
PR.erase(PR.begin()+N,PR.end());
// Processing end
vector<bool> vis(N);
vector<int> po;
for(int i=0;i<N;i++){
if(PR[i]==1)po.emplace_back(i);
}
for(int x=1;x<po.size();x++){
for(int i=po[x]-1;i>po[x-1];i--){
Remove(i);
vis[i]=true;
}
vis[po[x]]=true;
Remove(po[x]);
}
for(int i=0;i<N;i++)if(!vis[i])Remove(i);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |