Submission #64413

# Submission time Handle Problem Language Result Execution time Memory
64413 2018-08-04T11:04:53 Z Abelyan Saveit (IOI10_saveit) C++17
Compilation error
0 ms 0 KB
#include "grader.h"
#include "encoder.h"
#include <bits/stdc++.h>
using namespace std;
 
#define fr first
#define sc second
#define cout cerr
 
const int N=1006,H=40,P3[6]={1,3,9,27,81,243};
vector<int> g[N],graph[N];
int pars[N],pr[H][N];
bool col[N];
queue<pair<int,int> > q;
int dist[N][H];
 
void to_bit(int k){
    for (int i=9;i>=0;i--){
        if (k&(1<<i)){
            encode_bit(1);
        }
        else{
            encode_bit(0);
        }
    }
}
 
void dfs(int v,int p=-1){
    col[v]=true;
    for (int i=0;i<g[v].size();i++){
        int to=g[v][i];
        if (!col[to]) dfs(to,v);
    }
    pars[v]=p;
}
 
void dfshub(int v,int hub,int p=-1){
    //cout<<v<<" "<<hub<<" "<<p<<endl;
    for (int i=0;i<graph[v].size();i++){
        int to=graph[v][i];
        if (to!=p)dfshub(to,hub,v);
    }
    if (p!=-1)
        pr[hub][v]=p;
}
 
void encode(int n, int h, int m, int *a, int *b){
    for (int i=0;i<m;i++){
        g[a[i]].push_back(b[i]);
        g[b[i]].push_back(a[i]);
    }
    dfs(0);
    for (int i=0;i<h;i++){
        for (int j=0;j<n;j++)col[j]=false;
        q.push({i,0});
        col[i]=true;
        while(!q.empty()){
            int v=q.front().fr,len=q.front().sc;
            q.pop();
            dist[v][i]=len;
            for (int j=0;j<g[v].size();j++){
                int to=g[v][j];
                if (!col[to]){
                    q.push({to,len+1});
                    col[to]=true;
                }
            }
        }
    }
    /*
    for (int i=0;i<h;i++){
        for (int j=0;j<n;j++){
            cout<<dist[j][i]<<" ";
        }
        cout<<endl;
    }
    */
    for (int i=1;i<n;i++){
        to_bit(pars[i]);
        graph[i].push_back(pars[i]);
        graph[pars[i]].push_back(i);
    }
    for (int i=0;i<h;i++)dfshub(i,i);
    for (int i=0;i<n;i++){
        int ans=0;
        for (int j=0;j<36;j++){
            //if (j==2)cout<<dist[i][j]-dist[pr[j][i]][j]+1<<" ";
          if (j!=i)
            ans+=P3[(6-((j+1)%6))%6]*(dist[i][j]-dist[pr[j][i]][j]+1);
            if ((j+1)%6==0){
                to_bit(ans);
                //cout<<ans<<endl;
                ans=0;
            }
            //cout<<dist[i][j]-dist[pr[j][i]][j]+1<<" ";
        }
        //cout<<endl;
    }
}
#include "grader.h"
#include "decoder.h"
#include <bits/stdc++.h>
using namespace std;
 
#define fr first
#define sc second
#define cout cerr
 
const int N=1006,H=40,P3[6]={1,3,9,27,81,243};
vector<int> gr[N];
int tarb[N][H];
 
int to_dec(){
    int ans=0;
    for (int i=9;i>=0;i--){
        ans+=(1<<i)*decode_bit();
    }
    //cout<<ans<<endl;
    return ans;
}
 
void to_tr(int k,int arr[]){
    for (int i=5;i>=0;i--){
        arr[5-i]=k/P3[i];
        k%=P3[i];
    }
}
 
int dfsdec(int v,int ans,int hub,int par=-1){
    for (int i=0;i<gr[v].size();i++){
        int to=gr[v][i];
        if (to!=par)
            dfsdec(to,ans+tarb[to][hub]-1,hub,v);
    }
    hops(hub,v,ans);
}
 
void decode(int n, int h) {
    //cout<<"hi"<<endl;
    for (int i=1;i<n;i++){
        int p=to_dec();
        //cout<<p<<" ";
        gr[p].push_back(i);
        gr[i].push_back(p);
    }
    //cout<<endl;
    for (int i=0;i<n;i++){
        for (int j=0;j<6;j++){
            to_tr(to_dec(),tarb[i]+(j*6));
        }
        for (int j=0;j<36;j++){
            //cout<<tarb[i][j]<<" ";
        }
        //cout<<endl;
    }
    for (int i=0;i<h;i++){
        dfsdec(i,0,i);
    }
}

Compilation message

encoder.cpp:88:2: error: stray '\302' in program
           if (j!=i)
  ^
encoder.cpp:88:3: error: stray '\240' in program
           if (j!=i)
   ^
encoder.cpp:88:5: error: stray '\302' in program
           if (j!=i)
     ^
encoder.cpp:88:6: error: stray '\240' in program
           if (j!=i)
      ^
encoder.cpp:88:8: error: stray '\302' in program
           if (j!=i)
        ^
encoder.cpp:88:9: error: stray '\240' in program
           if (j!=i)
         ^
encoder.cpp:88:11: error: stray '\302' in program
           if (j!=i)
           ^
encoder.cpp:88:12: error: stray '\240' in program
           if (j!=i)
            ^
encoder.cpp:88:14: error: stray '\302' in program
           if (j!=i)
              ^
encoder.cpp:88:15: error: stray '\240' in program
           if (j!=i)
               ^
encoder.cpp:89:2: error: stray '\302' in program
             ans+=P3[(6-((j+1)%6))%6]*(dist[i][j]-dist[pr[j][i]][j]+1);
  ^
encoder.cpp:89:3: error: stray '\240' in program
             ans+=P3[(6-((j+1)%6))%6]*(dist[i][j]-dist[pr[j][i]][j]+1);
   ^
encoder.cpp:89:5: error: stray '\302' in program
             ans+=P3[(6-((j+1)%6))%6]*(dist[i][j]-dist[pr[j][i]][j]+1);
     ^
encoder.cpp:89:6: error: stray '\240' in program
             ans+=P3[(6-((j+1)%6))%6]*(dist[i][j]-dist[pr[j][i]][j]+1);
      ^
encoder.cpp:89:8: error: stray '\302' in program
             ans+=P3[(6-((j+1)%6))%6]*(dist[i][j]-dist[pr[j][i]][j]+1);
        ^
encoder.cpp:89:9: error: stray '\240' in program
             ans+=P3[(6-((j+1)%6))%6]*(dist[i][j]-dist[pr[j][i]][j]+1);
         ^
encoder.cpp:89:11: error: stray '\302' in program
             ans+=P3[(6-((j+1)%6))%6]*(dist[i][j]-dist[pr[j][i]][j]+1);
           ^
encoder.cpp:89:12: error: stray '\240' in program
             ans+=P3[(6-((j+1)%6))%6]*(dist[i][j]-dist[pr[j][i]][j]+1);
            ^
encoder.cpp:89:14: error: stray '\302' in program
             ans+=P3[(6-((j+1)%6))%6]*(dist[i][j]-dist[pr[j][i]][j]+1);
              ^
encoder.cpp:89:15: error: stray '\240' in program
             ans+=P3[(6-((j+1)%6))%6]*(dist[i][j]-dist[pr[j][i]][j]+1);
               ^
encoder.cpp:89:17: error: stray '\302' in program
             ans+=P3[(6-((j+1)%6))%6]*(dist[i][j]-dist[pr[j][i]][j]+1);
                 ^
encoder.cpp:89:18: error: stray '\240' in program
             ans+=P3[(6-((j+1)%6))%6]*(dist[i][j]-dist[pr[j][i]][j]+1);
                  ^
encoder.cpp: In function 'void dfs(int, int)':
encoder.cpp:30:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i=0;i<g[v].size();i++){
                  ~^~~~~~~~~~~~
encoder.cpp: In function 'void dfshub(int, int, int)':
encoder.cpp:39:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i=0;i<graph[v].size();i++){
                  ~^~~~~~~~~~~~~~~~
encoder.cpp: In function 'void encode(int, int, int, int*, int*)':
encoder.cpp:61:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for (int j=0;j<g[v].size();j++){
                          ~^~~~~~~~~~~~

decoder.cpp: In function 'int dfsdec(int, int, int, int)':
decoder.cpp:31:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i=0;i<gr[v].size();i++){
                  ~^~~~~~~~~~~~~
decoder.cpp:37:1: warning: no return statement in function returning non-void [-Wreturn-type]
 }
 ^