Submission #341759

# Submission time Handle Problem Language Result Execution time Memory
341759 2020-12-30T23:33:22 Z ogibogi2004 Saveit (IOI10_saveit) C++14
Compilation error
0 ms 0 KB
#include "grader.h"
#include "encoder.h"
#include<bits/stdc++.h>
using namespace std;
string s;
int dist[40][1024];
vector<int>g[1024];
void bfs(int u)
{
	queue<int>q;
	q.push(u);
	for(int i=0;i<1024;i++)
	{
		dist[u][i]=100000;
	}
	dist[u][u]=0;
	while(!q.empty())
	{
		int u1=q.front();
		q.pop();
		for(auto v:g[u1])
		{
			if(dist[u][u1]+1<dist[u][v])
			{
				dist[u][v]=dist[u][u1]+1;
				q.push(v);
			}
		}
	}
}
void encode(int nv, int nh, int ne, int *v1, int *v2){
  for(int i=0;i<ne;i++)
  {
	  g[v1[i]].push_back(v2[i]);
	  g[v2[i]].push_back(v1[i]);
  }
  for(int i=0;i<nh;i++)
  {
	  bfs(i);
  }
  for(int i=0;i<nh;i++)
  {
	  for(int j=i+1;j<nh;j++)
	  {
		  for(int l=0;l<10;l++)
		  {
			  if((1<<l)&dist[i][j])
			  {
				  s+='1';
			  }
			  else s+='0';
		  }
	  }
  }
  for(int i=nh;i<n;i++)
  {
	  pair<int,int>p={10000,10000};
	  for(int j=0;j<nh;j++)
	  {
		  p=min(p,{dist[j][i],j});
	  }
	  for(int l=0;l<6;l++)
	  {
		  if((1<<l)&p.second)
		  {
			  s+="1";
		  }
		  else s+="0";
	  }
	  for(int l=0;l<10;l++)
	  {
		  if((1<<l)&p.first)
		  {
			  s+="1";
		  }
		  else s+="0";
	  }
  }
  for(int i=0;i<s.size();i++)encode_bit(s[i]-'0');
  return;
}
#include "grader.h"
#include "decoder.h"
#include<bits/stdc++.h>
using namespace std;
int dist[42][42];
int closest[1024],dist_to_closest[1024];
void decode(int nv, int nh) {
	for(int i=0;i<nh;i++)
	{
		for(int j=i+1;j<nh;j++)
		{
			for(int l=0;l<10;l++)
			{
				int x=decode_bit();
				dist[i][j]+=(x<<l);
			}
			dist[j][i]=dist[i][j];
		}
	}
	for(int i=nh;i<n;i++)
	{
		for(int l=0;l<6;l++)
		{
			int x=decode_bit();
			cloesest[i]+=(x<<l);
		}
		for(int l=0;l<10;l++)
		{
			int x=decode_bit();
			dist_to_cloesest[i]+=(x<<l);
		}
	}
	for(int i=0;i<nh;i++)
	{
		for(int j=0;j<nh;j++)
		{
			hops(i,j,dist[i][j]);
		}
	}
	for(int i=nh;i<n;i++)
	{
		for(int j=0;j<nh;j++)
		{
			hops(j,i,dist_to_closest[i]+dist[closest[i]][j]);
		}
	}
}

Compilation message

encoder.cpp: In function 'void encode(int, int, int, int*, int*)':
encoder.cpp:55:18: error: 'n' was not declared in this scope
   55 |   for(int i=nh;i<n;i++)
      |                  ^
encoder.cpp:79:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   79 |   for(int i=0;i<s.size();i++)encode_bit(s[i]-'0');
      |               ~^~~~~~~~~

decoder.cpp: In function 'void decode(int, int)':
decoder.cpp:20:17: error: 'n' was not declared in this scope
   20 |  for(int i=nh;i<n;i++)
      |                 ^
decoder.cpp:25:4: error: 'cloesest' was not declared in this scope; did you mean 'closest'?
   25 |    cloesest[i]+=(x<<l);
      |    ^~~~~~~~
      |    closest
decoder.cpp:30:4: error: 'dist_to_cloesest' was not declared in this scope; did you mean 'dist_to_closest'?
   30 |    dist_to_cloesest[i]+=(x<<l);
      |    ^~~~~~~~~~~~~~~~
      |    dist_to_closest
decoder.cpp:40:17: error: 'n' was not declared in this scope
   40 |  for(int i=nh;i<n;i++)
      |                 ^