Submission #252845

# Submission time Handle Problem Language Result Execution time Memory
252845 2020-07-26T10:48:35 Z SamAnd Saveit (IOI10_saveit) C++17
Compilation error
0 ms 0 KB
//#include "grader.h"
#include "encoder.h"
#include "decoder.h"
#include <vector>
#include <algorithm>
#include <cstdio>
#include <map>
#include <set>
#include <queue>
using namespace std;
const int N = 1002;

int nn, m, u;
vector<int> a[N];
int d[N];
bool c[N];
void bfs(int x)
{
	for (int i = 0; i < nn; ++i)
	{
		c[i] = false;
		d[i] = 0;
	}
	queue<int> q;
	c[x] = true;
	q.push(x);
	while (!q.empty())
	{
		int x = q.front();
		q.pop();
		for (int i = 0; i < a[x].size(); ++i)
		{
			int h = a[x][i];
			if (!c[h])
			{
				c[h] = true;
				d[h] = d[x] + 1;
				q.push(h);
			}
		}
	}
}
void funkc()
{
	encode_bit(1);
	encode_bit(1);
	encode_bit(1);
	encode_bit(1);
	encode_bit(1);
	encode_bit(1);
	encode_bit(1);
	encode_bit(1);
	encode_bit(1);
	encode_bit(1);
}
void encode(int nv, int nh, int ne, int *v1, int *v2) {
	nn = nv;
	u = nh;
	m = ne;
	for (int i = 0; i < m; ++i)
	{
		a[v1[i]].push_back(v2[i]);
		a[v2[i]].push_back(v1[i]);
	}
	for (int i = 0; i < u; ++i)
	{
		bfs(i);
		for (int j = 0; j < nn; ++j)
		{
			vector<int> v;
			if (!d[j])
			{
				for (int k = 0; k<9; ++k)
					encode_bit(0);
				encode_bit(0);
				continue;
			}
			while (d[j])
			{
				v.push_back((d[j] % 2));
				d[j] /= 2;
			}
			for (int k = 0; k < (10 - v.size()); ++k)
			{
				encode_bit(0);
			}
			for (int k = v.size() - 1; k >= 0; --k)
			{
				encode_bit(v[k]);
			}
		}
	}
	return;
}
//#include "grader.h"
#include "encoder.h"
#include "decoder.h"
#include <vector>
#include <algorithm>
#include <cstdio>
#include <map>
#include <set>
#include <queue>
using namespace std;

void decode(int nv, int nh) {
	int v = 0;
	int u = 0;
	int n = 0;
	int i = 0;
	while (1)
	{
		++i;
		n *= 2;
		n += decode_bit();
		if (i % 10 == 0)
		{
			hops(v, u, n);
			++u;
			if (u == nv)
			{
				++v;
				u = 0;
			}
			if (v == nh)
			{
				break;
			}
			n = 0;
		}
	}
}

Compilation message

encoder.cpp: In function 'void bfs(int)':
encoder.cpp:31:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int i = 0; i < a[x].size(); ++i)
                   ~~^~~~~~~~~~~~~
encoder.cpp: In function 'void funkc()':
encoder.cpp:45:2: error: 'encode_bit' was not declared in this scope
  encode_bit(1);
  ^~~~~~~~~~
encoder.cpp:45:2: note: suggested alternative: 'encode'
  encode_bit(1);
  ^~~~~~~~~~
  encode
encoder.cpp: In function 'void encode(int, int, int, int*, int*)':
encoder.cpp:74:6: error: 'encode_bit' was not declared in this scope
      encode_bit(0);
      ^~~~~~~~~~
encoder.cpp:74:6: note: suggested alternative: 'encode'
      encode_bit(0);
      ^~~~~~~~~~
      encode
encoder.cpp:75:5: error: 'encode_bit' was not declared in this scope
     encode_bit(0);
     ^~~~~~~~~~
encoder.cpp:75:5: note: suggested alternative: 'encode'
     encode_bit(0);
     ^~~~~~~~~~
     encode
encoder.cpp:83:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for (int k = 0; k < (10 - v.size()); ++k)
                    ~~^~~~~~~~~~~~~~~~~
encoder.cpp:85:5: error: 'encode_bit' was not declared in this scope
     encode_bit(0);
     ^~~~~~~~~~
encoder.cpp:85:5: note: suggested alternative: 'encode'
     encode_bit(0);
     ^~~~~~~~~~
     encode
encoder.cpp:89:5: error: 'encode_bit' was not declared in this scope
     encode_bit(v[k]);
     ^~~~~~~~~~
encoder.cpp:89:5: note: suggested alternative: 'encode'
     encode_bit(v[k]);
     ^~~~~~~~~~
     encode

decoder.cpp: In function 'void decode(int, int)':
decoder.cpp:21:8: error: 'decode_bit' was not declared in this scope
   n += decode_bit();
        ^~~~~~~~~~
decoder.cpp:21:8: note: suggested alternative: 'decode'
   n += decode_bit();
        ^~~~~~~~~~
        decode
decoder.cpp:24:4: error: 'hops' was not declared in this scope
    hops(v, u, n);
    ^~~~