Submission #634437

#TimeUsernameProblemLanguageResultExecution timeMemory
634437PixelCatFlights (JOI22_flights)C++17
0 / 100
1 ms456 KiB
#include "Ali.h" #include <string> #include <vector> #define For(i, a, b) for(int i = a; i <= b; i++) #define Forr(i, a, b) for(int i = a; i >= b; i--) #define F first #define S second #define all(x) x.begin(),x.end() #define sz(x) ((int)x.size()) #define eb emplace_back using namespace std; namespace { const int MAXN = 10010; vector<int> adj[MAXN]; string tree; int cnt; void buildTree(int n, int p) { // SetID(n, cnt); cnt++; tree.push_back('1'); for(auto &i:adj[n]) if(i != p) { buildTree(i, n); } tree.push_back('0'); } } void Init(int N, std::vector<int> U, std::vector<int> V) { For(i, 0, N - 1) adj[i].clear(); For(i, 0, N - 2) { adj[U[i]].eb(V[i]); adj[V[i]].eb(U[i]); } cnt = 0; tree = ""; buildTree(0, 0); } std::string SendA(std::string S) { return tree; }
#include "Benjamin.h" #include <string> #include <vector> #include <cassert> #define For(i, a, b) for(int i = a; i <= b; i++) #define Forr(i, a, b) for(int i = a; i >= b; i--) #define F first #define S second #define all(x) x.begin(),x.end() #define sz(x) ((int)x.size()) #define eb emplace_back using namespace std; namespace { int x, y; int idx; string tree; const int MAXN = 10010; int d[MAXN]; int p[MAXN]; int cnt; void buildTree(int dep, int par) { assert(dep < MAXN); int n = cnt; cnt++; d[n] = dep; p[n] = par; while(tree[idx] == '1') { idx++; buildTree(dep + 1, n); } idx++; } int getDist(int a, int b) { int ans = 0; if(d[a] < d[b]) swap(a, b); while(d[a] > d[b]) { a = p[a]; ans++; } while(a != b) { a = p[a]; b = p[b]; ans += 2; } return ans; } } std::string SendB(int N, int X, int Y) { x = X; y = Y; return "00000111110000011111"; } int Answer(std::string T) { tree = T; idx = 1; cnt = 0; buildTree(1, 0); return getDist(x, y); }

Compilation message (stderr)

grader_ali.cpp:10:8: warning: '{anonymous}::_randmem' defined but not used [-Wunused-variable]
   10 |   char _randmem[12379];
      |        ^~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...