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 <vector>
#include "Alice.h"
#include <bits/stdc++.h>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<=int(b);i++)
#define rep(i,b) rng(i,0,b-1)
#define gnr(i,b,a) for(int i=int(b);i>=int(a);i--)
#define per(i,b) gnr(i,b-1,0)
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#define si(x) int(x.size())
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
typedef long long ll;
using pii=pair<int,int>;
using vi=vc<int>;
using uint=unsigned;
using ull=unsigned long long;
using pil=pair<int,ll>;
using pli=pair<ll,int>;
using pll=pair<ll,ll>;
using t3=tuple<int,int,int>;
// you may define some global variables, but it does not work if you try to transfer any information from function Alice() to function Bob() through these variables.
// you had better not use the same global variables in function Alice() and in function Bob().
std::vector<std::pair<int,int>> Alice(){
mt19937 gen(1557);
vi T;
rng(i,1,6*666) T.pb(1000+i);
shuffle(all(T), gen);
int N = 1000 + 6*666;
ll X = setN(N);
vi Z(6);
X--;
rep(i,6){
Z[i] = X%1000;
X/=1000;
}
vc<pii>res;
rng(i,2,1000){
res.pb({1,i});
}
rep(i,666){
rep(j,6){
res.pb({ (Z[j] + i)%1000 + 1, T[i*6+j]});
}
}
return res;
}
#include <vector>
#include "Bob.h"
#include <bits/stdc++.h>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<=int(b);i++)
#define rep(i,b) rng(i,0,b-1)
#define gnr(i,b,a) for(int i=int(b);i>=int(a);i--)
#define per(i,b) gnr(i,b-1,0)
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#define si(x) int(x.size())
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
typedef long long ll;
using pii=pair<int,int>;
using vi=vc<int>;
using uint=unsigned;
using ull=unsigned long long;
using pil=pair<int,ll>;
using pli=pair<ll,int>;
using pll=pair<ll,ll>;
using t3=tuple<int,int,int>;
// you may define some global variables, but it does not work if you try to transfer any information from function Alice() to function Bob() through these variables.
// you had better not use the same global variables in function Alice() and in function Bob().
long long Bob(std::vector<std::pair<int,int>> V){
mt19937 gen(1557);
vi T;
vc<pii> U(5010);
rng(i,1,6*666) T.pb(1000+i);
shuffle(all(T), gen);
rep(i,6*666){
U[T[i]]={i/6, i%6};
}
int R[6]={0};
for(auto [a,b]: V){
if(a>1000){
swap(a,b);
}
if(b>1000){
R[U[b].se] = a-1-U[b].fi;
while(R[U[b].se] < 0)R[U[b].se] += 1000;
}
}
ll s=1,t=1;
rep(i,6){
s += R[i]*t;
t*=1000;
}
return s;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |