Submission #101768

#TimeUsernameProblemLanguageResultExecution timeMemory
101768cheeheng한자 끝말잇기 (JOI14_kanji)C++14
10 / 100
133 ms19108 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...