# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1062370 | 12345678 | Flights (JOI22_flights) | C++17 | 5 ms | 1776 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;
const int nx=1e4+5;
int n, dist[nx];
vector<int> d[nx];
void dfs(int u, int p)
{
for (auto v:d[u]) if (v!=p) dist[v]=dist[u]+1, dfs(v, u);
}
void Init(int N, std::vector<int> U, std::vector<int> V) {
n=N;
for (int i=0; i<n; i++) d[i].clear();
for (int i=0; i<N-1; i++) d[U[i]].push_back(V[i]), d[V[i]].push_back(U[i]);
for (int i=0; i<N;i ++) SetID(i, i);
}
std::string SendA(std::string S) {
int x=0, y=0;
for (int i=0; i<14; i++) if (S[i]=='1') x+=(1<<i);
dfs(x, x);
for (int i=0; i<6; i++) if (S[i+14]=='1') y+=(1<<i);
string res;
for (int i=0; i<(1<<8); i++)
{
if ((i<<6)+y<n)
{
for (int j=0; j<14; j++)
{
if (dist[(i<<6)+y]&(1<<j)) res.push_back('1');
else res.push_back('0');
}
}
}
return res;
}
#include "Benjamin.h"
#include <bits/stdc++.h>
using namespace std;
int bn, bx, by, tmp;
std::string SendB(int N, int X, int Y) {
bn=N, bx=X, by=Y;
tmp=0;
string s;
for (int i=0; i<14; i++)
{
if (X&(1<<i)) s+='1';
else s+='0';
}
for (int i=0; i<6; i++)
{
tmp+=Y&(1<<i);
if (Y&(1<<i)) s+='1';
else s+='0';
}
return s;
}
int Answer(std::string T) {
int cur=0, res=0;
for (int i=0; i<(1<<8); i++)
{
if ((i<<6)+tmp==by)
{
for (int j=0; j<14; j++) res+=(T[cur+j]-'0')*(1<<j);
return res;
}
else if ((i<<6)+tmp<bn) cur+=14;
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |