Submission #591305

# Submission time Handle Problem Language Result Execution time Memory
591305 2022-07-07T09:00:46 Z 조영욱(#8419) Two Transportations (JOI19_transportations) C++17
0 / 100
258 ms 13432 KB
#include "Azer.h"
#include <bits/stdc++.h>
using namespace std;

namespace {

int n,m;
typedef pair<int,int> P;
vector<P> adj[2000];
bool vis[2000];
int dist[2000];
int variable_example[500000];
int cnt=0;
int ret[2000];
int s[2000];
int t[2000];
int d[2000];

}  // namespace

void InitA(int N, int A, std::vector<int> U, std::vector<int> V,
           std::vector<int> C) {
  n=N;
  m=U.size();
  for(int i=0;i<m;i++) {
    adj[U[i]].push_back(P(V[i],C[i]));
    adj[V[i]].push_back(P(U[i],C[i]));
  }
  if (n-1-m>1000) {
    for(int i=0;i<m;i++) {
        for(int j=0;j<11;j++) {
            if (U[i]&(1<<j)) {
                SendA(true);
            }
            else {
                SendA(false);
            }
        }
        for(int j=0;j<11;j++) {
            if (V[i]&(1<<j)) {
                SendA(true);
            }
            else {
                SendA(false);
            }
        }
        for(int j=0;j<9;j++) {
            if (C[i]&(1<<j)) {
                SendA(true);
            }
            else {
                SendA(false);
            }
        }
    }
  }
}

void ReceiveA(bool x) {
    if (n-1-m>1000) {
        ret[cnt/20]+=(x<<(cnt%20));
        cnt++;
        return;
    }
    int now=cnt%31;
    if (now<11) {
        s[cnt/31]+=(x<<now);
    }
    else if (now<22){
        now-=11;
        t[cnt/31]+=(x<<now);
    }
    else {
        now-=22;
        d[cnt/31]+=(x<<now);
    }
    cnt++;
}

std::vector<int> Answer() {
    if (n-1-m>1000) {
  std::vector<int> ans(n);
  for (int k = 0; k < n; ++k) {
    ans[k] = ret[k];
  }
  return ans;
    }
    for(int i=0;i<n-1-m;i++) {
        adj[s[i]].push_back(P(t[i],d[i]));
        adj[t[i]].push_back(P(s[i],d[i]));
    }
      for(int i=0;i<n;i++){
    dist[i]=1e7;
  }
  priority_queue<P,vector<P>,greater<P>> pq;
  pq.push(P(0,0));
  dist[0]=0;
  memset(vis,0,sizeof(vis));
  while (!pq.empty()) {
    int now=pq.top().second;
    pq.pop();
    if (vis[now]) {
        continue;
    }
    vis[now]=true;
    for(int i=0;i<adj[now].size();i++) {
        int nt=adj[now][i].first;
        if (dist[nt]>dist[now]+adj[now][i].second) {
            dist[nt]=dist[now]+adj[now][i].second;
            pq.push(P(dist[nt],nt));
        }
    }
  }
  std::vector<int> ans(n);
  for (int k = 0; k < n; ++k) {
    ans[k] = dist[k];
  }
  return ans;
}
#include "Baijan.h"
#include <bits/stdc++.h>
using namespace std;

namespace {

int n,m;
int cnt=0;

bool FunctionExample(bool P) {
  return !P;
}
typedef pair<int,int> P;
vector<P> adj[2000];
bool vis[2000];
int dist[2000];
int s[2000];
int t[2000];
int d[2000];
}  // namespace

void InitB(int N, int B, std::vector<int> S, std::vector<int> T,
           std::vector<int> D) {
    n=N;
    m=S.size();
    for(int i=0;i<m;i++) {
        adj[S[i]].push_back(P(T[i],D[i]));
        adj[T[i]].push_back(P(S[i],D[i]));
    }
    if (m<=1000) {
        for(int i=0;i<m;i++) {
            for(int j=0;j<11;j++) {
                if (S[i]&(1<<j)) {
                    SendB(true);
                }
                else {
                    SendB(false);
                }
            }
            for(int j=0;j<11;j++) {
                if (T[i]&(1<<j)) {
                    SendB(true);
                }
                else {
                    SendB(false);
                }
            }
            for(int j=0;j<9;j++) {
                if (D[i]&(1<<j)) {
                    SendB(true);
                }
                else {
                    SendB(false);
                }
            }
        }
        return;
    }
}

void ReceiveB(bool y) {
    int now=cnt%31;
    if (now<11) {
        s[cnt/31]+=(y<<now);
    }
    else if (now<22){
        now-=11;
        t[cnt/31]+=(y<<now);
    }
    else {
        now-=22;
        d[cnt/31]+=(y<<now);
    }
    cnt++;
    if (cnt/31==n-1-m) {
        for(int i=0;i<n-1-m;i++) {
            adj[s[i]].push_back(P(t[i],d[i]));
            adj[t[i]].push_back(P(s[i],d[i]));
        }
          for(int i=0;i<n;i++){
        dist[i]=1e7;
      }
      priority_queue<P,vector<P>,greater<P>> pq;
      pq.push(P(0,0));
      dist[0]=0;
      memset(vis,0,sizeof(vis));
      while (!pq.empty()) {
        int now=pq.top().second;
        pq.pop();
        if (vis[now]) {
            continue;
        }
        vis[now]=true;
        for(int i=0;i<adj[now].size();i++) {
            int nt=adj[now][i].first;
            if (dist[nt]>dist[now]+adj[now][i].second) {
                dist[nt]=dist[now]+adj[now][i].second;
                pq.push(P(dist[nt],nt));
            }
        }
      }
      for(int i=0;i<n;i++){
        for(int j=0;j<20;j++) {
            if (dist[i]&(1<<j)) {
                SendB(true);
            }
            else {
                SendB(false);
            }
        }
      }
    }
}

Compilation message

Azer.cpp: In function 'std::vector<int> Answer()':
Azer.cpp:106:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  106 |     for(int i=0;i<adj[now].size();i++) {
      |                 ~^~~~~~~~~~~~~~~~
Azer.cpp: At global scope:
Azer.cpp:12:5: warning: '{anonymous}::variable_example' defined but not used [-Wunused-variable]
   12 | int variable_example[500000];
      |     ^~~~~~~~~~~~~~~~

Baijan.cpp: In function 'void ReceiveB(bool)':
Baijan.cpp:94:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   94 |         for(int i=0;i<adj[now].size();i++) {
      |                     ~^~~~~~~~~~~~~~~~
Baijan.cpp: At global scope:
Baijan.cpp:10:6: warning: 'bool {anonymous}::FunctionExample(bool)' defined but not used [-Wunused-function]
   10 | bool FunctionExample(bool P) {
      |      ^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 784 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 672 KB Output is correct
2 Correct 190 ms 888 KB Output is correct
3 Incorrect 258 ms 944 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 215 ms 864 KB Output is correct
2 Correct 1 ms 656 KB Output is correct
3 Incorrect 2 ms 668 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 141 ms 712 KB Output is correct
2 Correct 167 ms 676 KB Output is correct
3 Correct 73 ms 13432 KB Output is correct
4 Incorrect 221 ms 868 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 141 ms 712 KB Output is correct
2 Correct 167 ms 676 KB Output is correct
3 Correct 73 ms 13432 KB Output is correct
4 Incorrect 221 ms 868 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 141 ms 712 KB Output is correct
2 Correct 167 ms 676 KB Output is correct
3 Correct 73 ms 13432 KB Output is correct
4 Incorrect 221 ms 868 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 784 KB Output isn't correct
2 Halted 0 ms 0 KB -