Submission #259485

#TimeUsernameProblemLanguageResultExecution timeMemory
259485mjkocijanTwo Transportations (JOI19_transportations)C++14
0 / 100
1376 ms23712 KiB
#include "Azer.h" #include <bits/stdc++.h> #define X first #define Y second using namespace std; typedef pair<int, int> ii; typedef long long ll; #define MAXN 2020 #define pb push_back #define INF 1001001001LL namespace { int N; //int variable_example[500000]; int cnt; vector<ii> g[MAXN]; int dist[MAXN]; set<ii> q; int getA, getB, getCnt = 0; int biobr = 0; unordered_map<ll, int> mp; } // namespace void obradiA() { ii cu = *q.begin(); q.erase(q.begin()); biobr++;//cout<<cu.X<<'/'<<cu.Y<<endl; for (ii i: g[cu.Y]) { if (dist[i.X] > dist[cu.Y] + i.Y) { if (q.count({dist[i.X], i.X})) q.erase({dist[i.X], i.X}); dist[i.X] = dist[cu.Y] + i.Y; q.insert({dist[i.X], i.X}); } } if (q.empty()) { if (biobr == N) return; SendA(0); return; for (int i = 0; i < 20; i++) SendA(0); for (int i = 0; i < 11; i++) SendA(0); return; } ii nx = *q.begin(); //if (mp.count(nx.X * INF + nx.Y)) { if (mp[nx.Y] > 1) { SendA(0); return; } SendA(1); //mp[nx.X * INF + nx.Y] = 1; mp[nx.Y]++; for (int i = 0; i < 20; i++) SendA(nx.X & (1 << i)); for (int i = 0; i < 11; i++) SendA(nx.Y & (1 << i)); } void InitA(int N, int A, std::vector<int> U, std::vector<int> V, std::vector<int> C) { ::N = N; if (N == 1) return; for (int i = 0; i < A; ++i) { //variable_example[i] = U[i] + V[i] - C[i]; g[U[i]].pb({V[i], C[i]}); g[V[i]].pb({U[i], C[i]}); } for (int i = 0; i < N; i++) { dist[i] = INF; } dist[0] = 0; q.insert({0, 0}); obradiA(); } int waitA = 1; void ReceiveA(bool x) {//cout<<x<<' '<<biobr<<endl; if (waitA && x) { waitA = 0; return; } if (waitA && !x) { obradiA(); return; } if (getCnt == 0) { getA = getB = 0; } getCnt++; if (getCnt <= 20) { if (x) getA |= (1 << (getCnt - 1)); } else if (x) getB |= (1 << (getCnt - 1 - 20)); if (getCnt == 20 + 11) { //cout << getA <<'.' << getB<<endl; //mp[getA * INF + getB] = 1; mp[getB]++; waitA = 1; if (dist[getB] > getA) { if (q.count({dist[getB], getB})) q.erase({dist[getB], getB}); dist[getB] = getA; q.insert({dist[getB], getB}); } getCnt = 0; obradiA(); } /*++cnt; if (cnt < 58000) { SendA(x); ++cnt; }*/ } std::vector<int> Answer() { if (N == 1) return vector<int>(1, 0); std::vector<int> ans(N); for (int k = 0; k < N; ++k) { ans[k] = dist[k]; //ans[k] = variable_example[k]; } return ans; }
#include "Baijan.h" #include <bits/stdc++.h> #define X first #define Y second using namespace std; typedef pair<int, int> ii; typedef long long ll; #define MAXN 2020 #define pb push_back #define INF 1001001001LL namespace { int N; int cnt; vector<ii> g[MAXN]; int dist[MAXN]; set<ii> q; int getA, getB, getCnt = 0; int biobr = 0; unordered_map<ll, int> mp; bool FunctionExample(bool P) { return !P; } } // namespace void obradiB() { ii cu = *q.begin(); q.erase(q.begin()); biobr++;//cout<<cu.X<<'|'<<cu.Y<<endl; for (ii i: g[cu.Y]) { if (dist[i.X] > dist[cu.Y] + i.Y) { if (q.count({dist[i.X], i.X})) q.erase({dist[i.X], i.X}); dist[i.X] = dist[cu.Y] + i.Y; q.insert({dist[i.X], i.X}); } } if (q.empty()) { if (biobr == N) return; SendB(0); return; for (int i = 0; i < 20; i++) SendB(0); for (int i = 0; i < 11; i++) SendB(0); return; } //if (cu.Y == 0) return; ii nx = *q.begin(); //if (mp.count(nx.X * INF + nx.Y)) { if (mp[nx.Y] > 1) { SendB(0); return; } SendB(1); //mp[nx.X * INF + nx.Y] = 1; mp[nx.Y]++; for (int i = 0; i < 20; i++) SendB(nx.X & (1 << i)); for (int i = 0; i < 11; i++) SendB(nx.Y & (1 << i)); } void InitB(int N, int B, std::vector<int> S, std::vector<int> T, std::vector<int> D) { ::N = N; if (N == 1) return; for (int i = 0; i < B; ++i) { //variable_example[i] = U[i] + V[i] - C[i]; g[S[i]].pb({T[i], D[i]}); g[T[i]].pb({S[i], D[i]}); } for (int i = 0; i < N; i++) { dist[i] = INF; } dist[0] = 0; q.insert({0, 0}); obradiB(); } int waitB = 1; void ReceiveB(bool y) {//cout<<y<<' '<<biobr<<".\n"; if (waitB && y) { waitB = 0; return; } if (waitB && !y) { obradiB(); return; } if (getCnt == 0) { getA = getB = 0; } getCnt++; if (getCnt <= 20) { if (y) getA |= (1 << (getCnt - 1)); } else if (y) getB |= (1 << (getCnt - 1 - 20)); if (getCnt == 20 + 11) { //cout << getA<<','<<getB<<endl; //mp[getA * INF + getB] = 1; mp[getB]++; waitB = 1; if (dist[getB] > getA) { if (q.count({dist[getB], getB})) q.erase({dist[getB], getB}); dist[getB] = getA; q.insert({dist[getB], getB}); } getCnt = 0; obradiB(); } }

Compilation message (stderr)

Azer.cpp:16:5: warning: '{anonymous}::cnt' defined but not used [-Wunused-variable]
 int cnt;
     ^~~

Baijan.cpp:23:6: warning: 'bool {anonymous}::FunctionExample(bool)' defined but not used [-Wunused-function]
 bool FunctionExample(bool P) {
      ^~~~~~~~~~~~~~~
Baijan.cpp:15:5: warning: '{anonymous}::cnt' defined but not used [-Wunused-variable]
 int cnt;
     ^~~
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...