답안 #601084

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
601084 2022-07-21T10:59:38 Z l_reho 저장 (Saveit) (IOI10_saveit) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;

vector<vector<int>> dist;
vector<vector<int>> graph;

struct info{
	int d;
	int node;
	
	bool operator< (const info& rhs) const {
        return d > rhs.d;
    }
	
};

void solver(int hub){
	
	queue<info> q;
	
	q.push({0, hub});
	dist[hub][hub] = 0;
	
	while(!q.empty()){
		info i = q.front();
		q.pop();
		
		int node = i.node;
		int d = i.d;
		
		vector<int> adj = graph[node];
		
		for(int a : adj){
			if(dist[hub][a] != INT_MAX) continue;
			dist[hub][a] = d+1;
			q.push({d+1, a});
		}
		
	}
	
}

void encode_bit(int bit);
int decode_bit();
void hops(int a, int b, int d);

void encode(int nv, int nh, int ne, int *v1, int *v2){
  // per ogni hub calcolo la distanza da ogni altro hub
	dist.assign(nv, vector<int>(nv, INT_MAX));
	graph.assign(nv, vector<int>());

	for(int i = 0; i < ne; i++){
		graph[v1[i]].push_back(v2[i]);
		graph[v2[i]].push_back(v1[i]);
	}
	
	for(int i = 0; i < nh; i++)
		solver(i);
	
	
	// adesso gli invio le informazioni
	
	for(int h = 0; h < nh; h++){
		for(int v = 0; v < nv; v++){
			
			// faccio l'encode di dist[h][v]
			string bts = "";
			
			while(dist[h][v]){
				// 11 bit
				char c = (dist[h][v] & 1) + '0';
				bts =  c + bts;
				dist[h][v] >>= 1;
			}
			bts = string(10-bts.length(), '0') + bts;
			// cout<<"DEBUG-->"<<bts.length()<<endl;
			for(char c : bts)
				encode_bit(c-'0');
		}
	}
  
	return;
}

void decode(int nv, int nh) {
	
	/*
   int a = decode_bit();
   int b = decode_bit();
   hops(0,0,0);
   hops(1,2,3);
   * */
   
   
	for(int h = 0; h < nh; h++){
		for(int v = 0; v < nv; v++){
			
			int d = 0;
			for(int i = 9; i >= 0; i--){
				int b = decode_bit();
				// cout<<"DEBUG-->"<<h<<" "<<v<<" "<<b<<endl;
				if(b) d += (1<<i);
			}
			
			
			hops(h, v, d);
			// decodifico e invio
			
		}
	}
}



    

Compilation message

/usr/bin/ld: /tmp/cc2tnwpd.o: in function `decode(int, int)':
encoder.cpp:(.text+0x41): undefined reference to `decode_bit()'
/usr/bin/ld: encoder.cpp:(.text+0x67): undefined reference to `hops(int, int, int)'
collect2: error: ld returned 1 exit status

/usr/bin/ld: /tmp/cc8Mmll0.o: in function `main':
grader_decoder.c:(.text.startup+0x126): undefined reference to `decode(int, int)'
collect2: error: ld returned 1 exit status