# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
561684 | fatemetmhr | Flights (JOI22_flights) | C++17 | 6 ms | 3396 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"
// Be name khoda //
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define all(x) x.begin(), x.end()
#define fi first
#define se second
namespace { // tole baze ha 20 hast
vector <int> adj[100000 + 10], eu;
int st[100000];
void dfs(int v, int par){
//cout << v << ' ' << par << endl;
st[v] = eu.size();
eu.pb(1);
for(auto u : adj[v]) if(u != par){
//cout << "v calling u " << v << ' ' << u << endl;
dfs(u, v);
eu.pb(0);
}
}
}
void Init(int N, std::vector<int> U, std::vector<int> V) {
for(int i = 0; i < N; i++)
adj[i].clear();
eu.clear();
//cout << "starting new query " << ' ' << N << ' ' << U.size() << ' ' << V.size() << endl;
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 < 30; i++)
eu.pb(0);
for(int i = 0; i < N; i++)
SetID(i, st[i]);
/*
variable_example++;
SetID(0, 0);
SetID(1, 1);
SetID(2, 2 * N + 19);
*/
//cout << "init done " << endl;
}
std::string SendA(std::string S) {
int id1 = 0, id2 = 0;
string s = S;
for(int i = 0; i < 10; i++) if(s[i] == '1')
id1 += (1 << i);
for(int i = 10; i < 20; i++) if(s[i] == '1')
id2 += (1 << (i - 10));
string t = "";
for(int i = id1 * 20; i < id1 * 20 + 20; i++)
t.pb(char('0' + eu[i])); // 0 yani -1 va bazgasht, 1 yani raft
for(int i = id2 * 20; i < id2 * 20 + 20; i++)
t.pb(char('0' + eu[i]));
if(id1 != id2){
ll sum = 0;
for(int i = id1 * 20 + 20; i < id2 * 20; i++)
sum += eu[i] ? 1 : -1;
int b = -1;
for(int i = 20; i >= 0; i--) if((sum >> i)&1){
b = i;
break;
}
if(b != -1){
for(int i = 0; i <= b; i++)
t.pb(char('0' + ((sum >> i)&1)));
}
}
return t;
}
#include "Benjamin.h"
// Be name khoda //
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define all(x) x.begin(), x.end()
#define fi first
#define se second
namespace {
int havex, havey, grx, gry;
}
std::string SendB(int N, int X, int Y) {
//cout << "having " << X << ' ' << Y << endl;
if(X > Y)
swap(X, Y);
havex = X;
havey = Y;
X /= 20;
Y /= 20;
grx = X;
gry = Y;
string s = "";
for(int i = 0; i < 10; i++)
s.pb(char('0' + ((X >> i)&1)));
for(int i = 0; i < 10; i++)
s.pb(char('0' + ((Y >> i)&1)));
//cout << "done " << endl;
return s;
}
int Answer(std::string T) {
havex %= 20;
havey %= 20;
int sum = 0;
if(grx == gry){
for(int i = havex + 1; i <= havey; i++)
sum += (T[i] == '0' ? -1 : 1);
//cout << "we are done " << endl;
return sum;
}
for(int i = havex + 1; i < grx * 20 + 20; i++)
sum += (T[i] == '0' ? -1 : 1);
for(int i = 0; i <= havey; i++)
sum += (T[i + 20] == '0' ? -1 : 1);
for(int i = 40; i < T.size(); i++) if(T[i] == '1')
sum += (1 << (i - 40));
//cout << "we are done with every thing " << endl;
return sum;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |