# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
588601 | Tekor | Flights (JOI22_flights) | C++17 | 52 ms | 1684 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 <string>
#include <vector>
namespace {
int variable_example = 0;
}
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
const int M = 2e4 + 100;
int n;
vector <int> g[M];
bool u[M];
int d[M],p[M];
void Init(int NN, std::vector<int> U, std::vector<int> V) {
n = NN;
srand(time(NULL));
for(int i = 0;i < n;i++)p[i] = i;
random_shuffle(p,p + n);
for(int i = 0;i < n;i++) {
g[i].clear();
u[i] = 0;
d[i] = 0;
SetID(i,p[i]);
}
for(int i = 0;i < U.size();i++) {
g[p[U[i]]].pb(p[V[i]]);
g[p[V[i]]].pb(p[U[i]]);
}
}
void bfs(int x) {
deque <int> q;
u[x] = 1;
q.pb(x);
while(!q.empty()) {
int v = q.front();
q.pop_front();
for(auto to : g[v]) {
if(u[to])continue;
d[to] = d[v] + 1;
u[to] = 1;
q.pb(to);
}
}
}
string trans(int x) {
string tek;
for(int i = 0;i <= 13;i++) {
if(x & (1 << i))tek += "1";
else tek += "0";
}
return tek;
}
string SendA(string S) {
int tek = 1,st = 0;
for(int i = 0;i <= 13;i++) {
if(S[i] == '1')st += tek;
tek *= 2;
}
tek = 1;
int fin = 0;
for(int i = 14;i < 20;i++) {
if(S[i] == '1')fin += tek;
tek *= 2;
}
bfs(st);
string ans;
for(int i = 0;i < n;i++) {
bool ch = 0;
for(int j = 0;j < 6;j++) {
if(((i & (1 << j)) && S[j + 14] == '0') || (!(i & (1 << j)) && S[j + 14] == '1')) {
ch = 1;
break;
}
}
if(!ch)ans += trans(d[i]);
}
return ans;
}
#include "Benjamin.h"
#include <string>
#include <vector>
namespace {
int variable_example = 0;
}
#include <bits/stdc++.h>
using namespace std;
string transf(int x) {
string tek;
for(int i = 0;i <= 13;i++) {
if(x & (1 << i))tek += "1";
else tek += "0";
}
return tek;
}
int star,finf,n;
std::string SendB(int NN, int X, int Y) {
n = NN;
star = X;
finf = Y;
string val = transf(X);
string val1 = transf(Y);
for(int i = 0;i < 6;i++) {
val += val1[i];
}
return val;
}
int Answer(std::string T) {
string val1 = transf(finf);
int L = 0;
for(int i = 0;i < n;i++) {
bool ch = 0;
for(int j = 0;j < 6;j++) {
if(((i & (1 << j)) && val1[j] == '0') || (!(i & (1 << j)) && val1[j] == '1')) {
ch = 1;
break;
}
}
if(ch)continue;
if(i == finf) {
int val = 0,tek = 1;
for(int j = L;j < L + 14;j++) {
if(T[j] == '1')val += tek;
tek = (tek * 2);
}
return val;
}
L += 14;
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |