Submission #566699

# Submission time Handle Problem Language Result Execution time Memory
566699 2022-05-22T16:50:05 Z Uzouf Saveit (IOI10_saveit) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
#include "grader.h"
#include "encoder.h"
 
void encode(int n,int h,int p,int a[],int b[]) {
  vector<vector<int> > v(n+t);
  int dis[n+5][n+5];
  for (int i=0;i<n+5;i++) {
      for (int j=0;j<n+5;j++) {
        dis[i][j]=2000;
      }
      dis[i][i]=0;
    }
 
    for (int i=0;i<p;i++) {
      v[a[i]].push_back(b[i]);
      v[b[i]].push_back(a[i]);
      dis[a[i]][b[i]]=dis[b[i]][a[i]]=1;
    }
 
    int par[n+5];
    for (int i=0;i<n+5;i++) par[i]=i;
    queue<int> q;
    q.push(0); par[0]=-1;
 
    while (!q.empty()) {
      int i=q.front();
      q.pop();
      for (int j:v[i]) {
        if (par[j]==j) {
          par[j]=i; q.push(j);
        }
      }
    }
    //tree:
    for (int i=0;i<n;i++) {
      if (par[i]==-1) par[i]=i;
      for (int pp=0;pp<10;pp++) {
        if (((1<<pp)&par[i])==0) encode_bit(0);
        else encode_bit(1);
      }
    }
 
 
    for (int hub=1;hub<h;hub++) {
      //cout<<hub<<":"<<endl;
      int dis[n+5];
      bool vis[n+5];
      for (int i=0;i<n;i++) {
        vis[i]=false;
      }
      queue<int> q;
      q.push(hub); dis[hub]=0; vis[hub]=true;
 
      while (!q.empty()) {
        int i=q.front();
        q.pop();
        for (int j:v[i]) {
          if (!vis[j]) {
            vis[j]=true; dis[j]=dis[i]+1; q.push(j);
          }
        }
      }
 
      for (int i=0;i<n;i++) {
        int nm=dis[i]-dis[par[i]];
        //cout<<i<<' '<<par[i]<<"  "<<dis[i]<<' '<<dis[par[i]]<<' '<<nm<<endl;
        if (nm==0) {encode_bit(0);continue;}
        encode_bit(1);
        if (nm==1) encode_bit(0);
        else encode_bit(1);
      }
    }
}
#include <bits/stdc++.h>
using namespace std;
#include "grader.h"
#include "encoder.h"
 
void decode(int n,int h) {
  vector<vector<int> > v(n+5);
  int par[n+5];
  for (int i=0;i<n;i++) {
    int tmp=0;
    for (int p=0;p<10;p++) {
      tmp+=(decode_bit()*(1<<p));
    }
    par[i]=tmp;
    v[i].push_back(tmp); v[tmp].push_back(i);
  }
 
  for (int hub=0;hub<h;hub++) {
    int dis[n+5][n+5];
 
    if (hub>0) {
      for (int i=0;i<n;i++) {
        int tmp=decode_bit();
        if (tmp==0) {
          dis[i][par[i]]=0; dis[par[i]][i]=0;
        }
        else {
          tmp=decode_bit();
          if (tmp==0) {
            dis[par[i]][i]=1; dis[i][par[i]]=-1;
          }
          else {
            dis[i][par[i]]=1; dis[par[i]][i]=-1;
          }
        }
      }
    }
    else {
      for (int i=0;i<n;i++) {
        for (int j=0;j<n;j++) dis[i][j]=1;
      }
    }
 
    queue<int> q;
    int ans[n+5];
    bool vis[n+5];
    memset(vis,false,sizeof vis);
    ans[hub]=0; q.push(hub); vis[hub]=true;
 
    while (!q.empty()) {
      int i=q.front();
      q.pop();
      hops(hub,i,ans[i]);
 
      for (int j:v[i]) {
        if (!vis[j]) {
          q.push(j); ans[j]=ans[i]+dis[i][j]; vis[j]=true;
        }
      }
    }
 
  }
 
}

Compilation message

encoder.cpp: In function 'void encode(int, int, int, int*, int*)':
encoder.cpp:7:28: error: 't' was not declared in this scope
    7 |   vector<vector<int> > v(n+t);
      |                            ^