답안 #341767

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
341767 2020-12-31T00:42:54 Z ogibogi2004 저장 (Saveit) (IOI10_saveit) C++14
75 / 100
284 ms 15584 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');
      |               ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 284 ms 15584 KB Output is partially correct - 70290 call(s) of encode_bit()
2 Correct 6 ms 9008 KB Output is correct - 100 call(s) of encode_bit()
3 Correct 28 ms 10492 KB Output is correct - 63350 call(s) of encode_bit()
4 Correct 5 ms 9184 KB Output is correct - 140 call(s) of encode_bit()
5 Correct 32 ms 10464 KB Output is correct - 63350 call(s) of encode_bit()
6 Correct 34 ms 10828 KB Output is partially correct - 70290 call(s) of encode_bit()
7 Correct 54 ms 10976 KB Output is partially correct - 70290 call(s) of encode_bit()
8 Correct 33 ms 10544 KB Output is correct - 67560 call(s) of encode_bit()
9 Correct 33 ms 10512 KB Output is partially correct - 70290 call(s) of encode_bit()
10 Correct 32 ms 10512 KB Output is partially correct - 70290 call(s) of encode_bit()
11 Correct 36 ms 10592 KB Output is partially correct - 70290 call(s) of encode_bit()
12 Correct 31 ms 10464 KB Output is partially correct - 70290 call(s) of encode_bit()
13 Correct 72 ms 11104 KB Output is partially correct - 70290 call(s) of encode_bit()
14 Correct 33 ms 10640 KB Output is partially correct - 70290 call(s) of encode_bit()
15 Correct 32 ms 10592 KB Output is partially correct - 70290 call(s) of encode_bit()
16 Correct 58 ms 11232 KB Output is partially correct - 70290 call(s) of encode_bit()
17 Correct 54 ms 10976 KB Output is partially correct - 70290 call(s) of encode_bit()
18 Correct 66 ms 11232 KB Output is partially correct - 70290 call(s) of encode_bit()
19 Correct 45 ms 10916 KB Output is partially correct - 70290 call(s) of encode_bit()
20 Correct 79 ms 11616 KB Output is partially correct - 70290 call(s) of encode_bit()
21 Correct 91 ms 11840 KB Output is partially correct - 70290 call(s) of encode_bit()
22 Correct 62 ms 11232 KB Output is partially correct - 70290 call(s) of encode_bit()
23 Correct 86 ms 11872 KB Output is partially correct - 70290 call(s) of encode_bit()
# 결과 실행 시간 메모리 Grader output
1 Correct 284 ms 15584 KB Output is partially correct - 70290 call(s) of encode_bit()
2 Correct 6 ms 9008 KB Output is correct - 100 call(s) of encode_bit()
3 Correct 28 ms 10492 KB Output is correct - 63350 call(s) of encode_bit()
4 Correct 5 ms 9184 KB Output is correct - 140 call(s) of encode_bit()
5 Correct 32 ms 10464 KB Output is correct - 63350 call(s) of encode_bit()
6 Correct 34 ms 10828 KB Output is partially correct - 70290 call(s) of encode_bit()
7 Correct 54 ms 10976 KB Output is partially correct - 70290 call(s) of encode_bit()
8 Correct 33 ms 10544 KB Output is correct - 67560 call(s) of encode_bit()
9 Correct 33 ms 10512 KB Output is partially correct - 70290 call(s) of encode_bit()
10 Correct 32 ms 10512 KB Output is partially correct - 70290 call(s) of encode_bit()
11 Correct 36 ms 10592 KB Output is partially correct - 70290 call(s) of encode_bit()
12 Correct 31 ms 10464 KB Output is partially correct - 70290 call(s) of encode_bit()
13 Correct 72 ms 11104 KB Output is partially correct - 70290 call(s) of encode_bit()
14 Correct 33 ms 10640 KB Output is partially correct - 70290 call(s) of encode_bit()
15 Correct 32 ms 10592 KB Output is partially correct - 70290 call(s) of encode_bit()
16 Correct 58 ms 11232 KB Output is partially correct - 70290 call(s) of encode_bit()
17 Correct 54 ms 10976 KB Output is partially correct - 70290 call(s) of encode_bit()
18 Correct 66 ms 11232 KB Output is partially correct - 70290 call(s) of encode_bit()
19 Correct 45 ms 10916 KB Output is partially correct - 70290 call(s) of encode_bit()
20 Correct 79 ms 11616 KB Output is partially correct - 70290 call(s) of encode_bit()
21 Correct 91 ms 11840 KB Output is partially correct - 70290 call(s) of encode_bit()
22 Correct 62 ms 11232 KB Output is partially correct - 70290 call(s) of encode_bit()
23 Correct 86 ms 11872 KB Output is partially correct - 70290 call(s) of encode_bit()
# 결과 실행 시간 메모리 Grader output
1 Correct 284 ms 15584 KB Output is partially correct - 70290 call(s) of encode_bit()
2 Correct 6 ms 9008 KB Output is correct - 100 call(s) of encode_bit()
3 Correct 28 ms 10492 KB Output is correct - 63350 call(s) of encode_bit()
4 Correct 5 ms 9184 KB Output is correct - 140 call(s) of encode_bit()
5 Correct 32 ms 10464 KB Output is correct - 63350 call(s) of encode_bit()
6 Correct 34 ms 10828 KB Output is partially correct - 70290 call(s) of encode_bit()
7 Correct 54 ms 10976 KB Output is partially correct - 70290 call(s) of encode_bit()
8 Correct 33 ms 10544 KB Output is correct - 67560 call(s) of encode_bit()
9 Correct 33 ms 10512 KB Output is partially correct - 70290 call(s) of encode_bit()
10 Correct 32 ms 10512 KB Output is partially correct - 70290 call(s) of encode_bit()
11 Correct 36 ms 10592 KB Output is partially correct - 70290 call(s) of encode_bit()
12 Correct 31 ms 10464 KB Output is partially correct - 70290 call(s) of encode_bit()
13 Correct 72 ms 11104 KB Output is partially correct - 70290 call(s) of encode_bit()
14 Correct 33 ms 10640 KB Output is partially correct - 70290 call(s) of encode_bit()
15 Correct 32 ms 10592 KB Output is partially correct - 70290 call(s) of encode_bit()
16 Correct 58 ms 11232 KB Output is partially correct - 70290 call(s) of encode_bit()
17 Correct 54 ms 10976 KB Output is partially correct - 70290 call(s) of encode_bit()
18 Correct 66 ms 11232 KB Output is partially correct - 70290 call(s) of encode_bit()
19 Correct 45 ms 10916 KB Output is partially correct - 70290 call(s) of encode_bit()
20 Correct 79 ms 11616 KB Output is partially correct - 70290 call(s) of encode_bit()
21 Correct 91 ms 11840 KB Output is partially correct - 70290 call(s) of encode_bit()
22 Correct 62 ms 11232 KB Output is partially correct - 70290 call(s) of encode_bit()
23 Correct 86 ms 11872 KB Output is partially correct - 70290 call(s) of encode_bit()
# 결과 실행 시간 메모리 Grader output
1 Correct 284 ms 15584 KB Output is partially correct - 70290 call(s) of encode_bit()
2 Correct 6 ms 9008 KB Output is correct - 100 call(s) of encode_bit()
3 Correct 28 ms 10492 KB Output is correct - 63350 call(s) of encode_bit()
4 Correct 5 ms 9184 KB Output is correct - 140 call(s) of encode_bit()
5 Correct 32 ms 10464 KB Output is correct - 63350 call(s) of encode_bit()
6 Correct 34 ms 10828 KB Output is partially correct - 70290 call(s) of encode_bit()
7 Correct 54 ms 10976 KB Output is partially correct - 70290 call(s) of encode_bit()
8 Correct 33 ms 10544 KB Output is correct - 67560 call(s) of encode_bit()
9 Correct 33 ms 10512 KB Output is partially correct - 70290 call(s) of encode_bit()
10 Correct 32 ms 10512 KB Output is partially correct - 70290 call(s) of encode_bit()
11 Correct 36 ms 10592 KB Output is partially correct - 70290 call(s) of encode_bit()
12 Correct 31 ms 10464 KB Output is partially correct - 70290 call(s) of encode_bit()
13 Correct 72 ms 11104 KB Output is partially correct - 70290 call(s) of encode_bit()
14 Correct 33 ms 10640 KB Output is partially correct - 70290 call(s) of encode_bit()
15 Correct 32 ms 10592 KB Output is partially correct - 70290 call(s) of encode_bit()
16 Correct 58 ms 11232 KB Output is partially correct - 70290 call(s) of encode_bit()
17 Correct 54 ms 10976 KB Output is partially correct - 70290 call(s) of encode_bit()
18 Correct 66 ms 11232 KB Output is partially correct - 70290 call(s) of encode_bit()
19 Correct 45 ms 10916 KB Output is partially correct - 70290 call(s) of encode_bit()
20 Correct 79 ms 11616 KB Output is partially correct - 70290 call(s) of encode_bit()
21 Correct 91 ms 11840 KB Output is partially correct - 70290 call(s) of encode_bit()
22 Correct 62 ms 11232 KB Output is partially correct - 70290 call(s) of encode_bit()
23 Correct 86 ms 11872 KB Output is partially correct - 70290 call(s) of encode_bit()