답안 #143489

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
143489 2019-08-14T09:47:15 Z tincamatei Data Transfer (IOI19_transfer) C++14
컴파일 오류
0 ms 0 KB
public class transfer {
	
	int[] get_attachment(int[] source) {
		int N = source.length;
		int K;
		int[] attach;
		
		if(N == 63)
			K = 7;
		else
			K = 9;
		
		attach = new int[K];
		
		for(int i = 0; i < K - 1; ++i) {
			int xorsum = 0;
			for(int j = 0; j < N; ++j)
				if((j & (1 << i)) != 0)
					xorsum = (xorsum ^ source[j]);
			attach[i] = xorsum;
		}
		
		int totalxorsum = 0;
		for(int j = 0; j < N; ++j)
			totalxorsum ^= source[j];
		attach[K - 1] = totalxorsum;
		
		return attach;
	}
	
	int[] retrieve(int[] data) {
		int N, K;
		int[] rez;
		
		if(data.length == 63 + 7) {
			N = 63;
			K = 7;
		} else {
			N = 255;
			K = 9;
		}
		
		rez = new int[N];
		int xorsum = 0;
		for(int i = 0; i < N; ++i)
			xorsum ^= data[i];
		
		if(data[N + K - 1] != xorsum) {
			int broken = 0;
			for(int i = 0; i < K - 1; ++i) {
				xorsum = 0;
				for(int j = 0; j < N; ++j)
					if((j & (1 << i)) != 0)
						xorsum ^= data[j];
				if(xorsum != data[N + i])
					broken = (broken ^ (1 << i));
			}
			data[broken] ^= 1;
		}
		for(int j = 0; j < N; ++j)
			rez[j] = data[j];
		
		return rez;
	}
}

Compilation message

transfer.cpp:2:1: error: expected unqualified-id before 'public'
 public class transfer {
 ^~~~~~