답안 #341766

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
341766 2020-12-31T00:42:08 Z ogibogi2004 저장 (Saveit) (IOI10_saveit) C++14
컴파일 오류
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];
vector<int>g1[1024];
int par[1024];
int f[1024][40];
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);
			}
		}
	}
}
bool vis[1024];
void dfs(int u,int p)
{
	vis[u]=1;
	par[u]=p;
	for(auto v:g[u])
	{
		if(vis[v])continue;
		dfs(v,u);
	}
}
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);
  }
  dfs(0,-1);
  for(int i=1;i<nv;i++)
  {
	  for(int j=0;j<nh;j++)
	  {
		  f[i][j]=dist[j][i]-dist[j][par[i]];
	  }
  }
  for(int i=1;i<nv;i++)
  {
	  for(int l=0;l<10;l++)
	  {
		  if(par[i]&(1<<l))s+="1";
		  else s+="0";
	  }
  }
  for(int l=0;l<nh;l++)
  {
	  for(int k=0;k<10;k++)
	  {
		  if(dist[l][0]&(1<<k))s+="1";
		  else s+="0";
	  }
	  for(int i=1;i<nv;i+=3)
	  {
		  int p=0;
		  p=(f[i][l]+1)*9+(f[i+1][l]+1)*3+f[i+2][l]+1;
		  for(int j=0;j<5;j++)
		  {
			  if(p&(1<<j))
			  {
				  s+="1";
			  }
			  else s+="0";
		  }
	  }
  }
  /*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<nv;i++)
  {
	  int smallest=100000;
	  vector<int>v;
	  for(int j=0;j<nh;j++)
	  {
		  if(dist[j][i]<smallest)
		  {
			  smallest=dist[j][i];
			  v.clear();
		  }
		  if(dist[j][i]==smallest)
		  {
			  v.push_back(j);
		  }
	  }
	  bool b[40];
	  memset(b,0,sizeof(b));
	  for(auto xd:v)b[xd]=1;
	  for(int l=0;l<nh;l++)
	  {
		  if(b[l])s+="1";
		  else s+="0";
	  }
	  for(int l=0;l<10;l++)
	  {
		  if((1<<l)&smallest)
		  {
			  s+="1";
		  }
		  else s+="0";
	  }
  }*/
  for(int i=0;i<s.size();i++)encode_bit((int)s[i]-'0');
  return;
}
#include "grader.h"
#include "decoder.h"
#include<bits/stdc++.h>
using namespace std;
//int dist[1024][1024];
int dist_to_closest[1024];
vector<int>closest[1024];
//int par[1024];
//vector<int>g[1024];
//int f[1024][64];
int gg;
void dfs(int u)
{
	for(auto v:g[u])
	{
		for(int j=0;j<gg;j++)
		{
			dist[v][j]=dist[u][j]+f[v][j];
		}
		dfs(v);
	}
}
void decode(int nv, int nh) {
	gg=nh;
	memset(dist,0,sizeof(dist));
	memset(f,0,sizeof(f));
	memset(par,0,sizeof(par));
	for(int i=0;i<nv;i++)g[i].clear();
	for(int i=1;i<nv;i++)
	{
		int p=0;
		for(int l=0;l<10;l++)
		{
			int x=decode_bit();
			p+=(x<<l);
		}
		par[i]=p;
		g[p].push_back(i);
	}
	for(int i=0;i<nh;i++)
	{
		for(int l=0;l<10;l++)
		{
			int x=decode_bit();
			dist[0][i]+=(x<<l);
		}
		for(int j=1;j<nv;j+=3)
		{
			int p=0;
			for(int l=0;l<5;l++)
			{
				int x=decode_bit();
				p+=(x<<l);
			}
			f[j][i]=p/9-1;
			f[j+1][i]=(p/3)%3-1;
			f[j+2][i]=p%3-1;
		}
	}
	dfs(0);
	for(int i=0;i<nh;i++)
	{
		for(int j=0;j<nv;j++)
		{
			hops(i,j,dist[j][i]);
		}
	}
}

Compilation message

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

decoder.cpp: In function 'void dfs(int)':
decoder.cpp:14:13: error: 'g' was not declared in this scope
   14 |  for(auto v:g[u])
      |             ^
decoder.cpp:18:4: error: 'dist' was not declared in this scope
   18 |    dist[v][j]=dist[u][j]+f[v][j];
      |    ^~~~
decoder.cpp:18:26: error: 'f' was not declared in this scope
   18 |    dist[v][j]=dist[u][j]+f[v][j];
      |                          ^
decoder.cpp: In function 'void decode(int, int)':
decoder.cpp:25:9: error: 'dist' was not declared in this scope
   25 |  memset(dist,0,sizeof(dist));
      |         ^~~~
decoder.cpp:26:9: error: 'f' was not declared in this scope
   26 |  memset(f,0,sizeof(f));
      |         ^
decoder.cpp:27:9: error: 'par' was not declared in this scope
   27 |  memset(par,0,sizeof(par));
      |         ^~~
decoder.cpp:28:23: error: 'g' was not declared in this scope
   28 |  for(int i=0;i<nv;i++)g[i].clear();
      |                       ^
decoder.cpp:38:3: error: 'g' was not declared in this scope
   38 |   g[p].push_back(i);
      |   ^