# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1004057 | edogawa_something | Flights (JOI22_flights) | C++17 | 280 ms | 31064 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 "Ali.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vii;
typedef pair<ll,ll> pii;
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define pb push_back
const int M=1000000;
const ll inf=1e9+10;
vii adj[M];
ll id[M],dis[M];
ll t=0;
ll n;
vii v;
void dfs(ll x,ll pa){
id[x]=t++;
for(auto it:adj[x]){
if(it==pa)
continue;
dfs(it,x);
}
}
string res;
void ord(ll x,ll pa=-1,ll d=0){
dis[x]=d;
for(auto it:adj[x]){
if(it==pa)
continue;
ord(it,x,d+1);
}
}
void Init(int N, std::vector<int> U, std::vector<int> V) {
n=N;
for(int i=0;i<n;i++)
adj[i].clear();
for(int i=0;i<n-1;i++)
adj[U[i]].pb(V[i]),adj[V[i]].pb(U[i]);
dfs(0,-1);
for(int i=0;i<n;i++)
SetID(i,i);
}
string encode(ll x){
string res;
for(int i=0;i<14;i++){
if((x&(1<<i))>0)
res.pb('1');
else
res.pb('0');
}
return res;
}
std::string SendA(std::string S){
res.clear();
v.clear();
v.pb(0);
v.pb((1<<10));
v.pb((1<<11));
v.pb((1<<10)+(1<<11));
v.pb((1<<12));
v.pb((1<<12)+(1<<10));
v.pb((1<<12)+(1<<11));
v.pb((1<<12)+(1<<11)+(1<<10));
v.pb((1<<13));
v.pb((1<<13)+(1<<10));
ll a=0,b=0;
for(int i=0;i<10;i++)
a+=(1<<i)*(S[i]=='1');
for(int i=10;i<20;i++)
b+=(1<<(i-10))*(S[i]=='1');
for(auto it:v){
for(int i=0;i<n;i++)
dis[i]=0;
ord(a+it,-1);
for(auto itt:v){
res+=encode(dis[b+itt]);
}
}
return res;
}
#include "Benjamin.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vii;
typedef pair<ll,ll> pii;
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define pb push_back
namespace {
const ll M=1e5;
const ll inf=1e18;
ll n,x,y,pa[M],dis[M];
vii adj[M];
vii v;
void dfs(ll x,ll pa=-1,ll d=0){
dis[x]=d;
for(auto it:adj[x]){
if(it==pa)
continue;
dfs(it,x,d+1);
}
}
}
std::string SendB(int N, int X, int Y) {
n=N,x=X,y=Y;
string r;
for(int i=0;i<10;i++){
if((x&(1<<i))>0)
r+='1';
else
r+='0';
}
for(int i=0;i<10;i++){
if((y&(1<<i))>0)
r+='1';
else
r+='0';
}
return r;
}
int Answer(std::string T) {
ll xx,yy;
xx=0,yy=0;
v.clear();
v.pb(0);
v.pb((1<<10));
v.pb((1<<11));
v.pb((1<<10)+(1<<11));
v.pb((1<<12));
v.pb((1<<12)+(1<<10));
v.pb((1<<12)+(1<<11));
v.pb((1<<12)+(1<<11)+(1<<10));
v.pb((1<<13));
v.pb((1<<13)+(1<<10));
for(int i=0;i<10;i++){
if((x&(1<<i)))
xx+=(1<<i);
if((y&(1<<i)))
yy+=(1<<i);
}
ll ans=0;
ll ind=0;
bool chk=0;
for(int i=0;i<10;i++){
if(chk)
break;
for(int j=0;j<10;j++){
if(xx+v[i]==x&&yy+v[j]==y){
chk=1;
break;
}
ind+=14;
}
}
for(int i=ind;i<ind+14;i++){
ans+=(1<<(i-ind))*(T[i]=='1');
}
return ans;
}
/*
g++ -std=c++17 -O2 -o grader grader.cpp Ali.cpp Benjamin.cpp
*/
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |