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 "Annalib.h"
#include <bits/stdc++.h>
using namespace std;
void Anna(int N, int M, int A[], int B[], long long C[], int Q, int S[], int T[], int K, int U[]){
for(int i = 0; i < K; i ++){
long long temp = C[U[i]];
for(int i = 53; i >= 0; i --){
if(temp&(1LL<<i)){
Tap(1);
}else{
Tap(0);
}
}
}
}
#include "Brunolib.h"
#include <bits/stdc++.h>
using namespace std;
const long long INF = 4e18;
typedef pair<long long, long long> ii;
vector<ii> AdjList[305];
long long dist[305];
int p[305];
int EdgeList[305][305];
void Bruno(int N, int M, int A[], int B[], long long C[], int Q, int S[], int T[], int K, int U[], int L, int X[]) {
int cnt = 0;
for(int k = 0; k < 5; k ++){
C[U[k]] = 0;
for(int i = 53; i >= 0; i --){
C[U[k]] |= (long long)X[cnt++] << i;
}
}
memset(EdgeList, -1, sizeof(EdgeList));
for(int i = 0; i < M; i ++){
AdjList[A[i]].push_back(ii(B[i], C[i]));
EdgeList[A[i]][B[i]] = i;
}
for(int i = 0; i < Q; i ++){
memset(p, -1, sizeof(p));
for(int j = 0; j < N; j ++){
dist[j] = INF;
}
dist[S[i]] = 0;
priority_queue<ii, vector<ii>, greater<ii> > pq;
pq.push(ii(0, S[i]));
//printf("3\n");
while(!pq.empty()){
ii temp = pq.top(); pq.pop();
long long d = temp.first;
int u = temp.second;
//printf("%d %d %lld\n", T[i], u, d);
if(d > dist[u]){continue;}
for(ii v: AdjList[u]){
if(dist[v.first] > dist[u] + v.second){
dist[v.first] = dist[u] + v.second;
p[v.first] = u;
pq.push(ii(dist[v.first], v.first));
}
}
}
vector<int> stack1;
int temp = T[i];
do{
stack1.push_back(temp);
temp = p[temp];
}while(temp != -1);
reverse(stack1.begin(), stack1.end());
//printf("dist[T[i]] = %lld\n", dist[T[i]]);
for(int i = 1; i < (int)stack1.size(); i ++){
//printf("%d %d %d\n", stack1[i-1], stack1[i], EdgeList[stack1[i-1]][stack1[i]]);
Answer(EdgeList[stack1[i-1]][stack1[i]]);
}
//printf("\n");
Answer(-1);
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |