답안 #829642

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
829642 2023-08-18T13:43:50 Z Essa2006 Data Transfer (IOI19_transfer) C++14
0 / 100
8 ms 5628 KB
#include "transfer.h"
#include<bits/stdc++.h>

using namespace std;

vector<int> get_attachment(vector<int> source) {
    int n=255;
	for(int j=0;j<=9;j++){
        int cur=(1<<j);
        int res=0;
        for(int i=cur;i<=n;i+=cur){
            res^=source[i];
        }
        source.push_back(res);
	}
	source.push_back(source.front());
	return source;
}

vector<int> retrieve(vector<int> data) {
	int ind=0;
	int n=255;
	vector<int>Cur(n);
	for(int j=0;j<=9;j++){
        int cur=(1<<j);
        int res=0;
        for(int i=cur;i<256;i+=cur){
            res^=data[i];
        }
        Cur.push_back(res);
	}
	for(int i=n;i<data.size();i++){
        if(Cur[i]!=data[i])
            ind+=(1<<(i-n));
	}
	vector<int>Ans;
	for(int i=0;i<n;i++){
        Ans.push_back(data[i]);
	}
	if(ind || (ind==0 && data.back()!=Ans.front())){
        Ans[ind]=!Ans[ind];
	}
	return Ans;
}
//
//
//static inline string run_scenario() {
//	int c;
//	cin >> c;
//	if (c < -1)
//		return "invalid corruption index";
//	string source_str;
//	cin >> source_str;
//	const int N = source_str.size();
//	const int max_attachment_size = 2*N;
//	vector<int> source;
//	for (int i=0; i<N; i++)
//		source.push_back(source_str[i]-'0');
//
//	vector<int> attachment = get_attachment(source);
//	if (int(attachment.size()) > max_attachment_size)
//		return "attachment too large";
//	for (int x : attachment)
//		if (x != 0 && x != 1)
//			return "invalid attachment integer value";
//
//	vector<int> data(source);
//	data.insert(data.end(), attachment.begin(), attachment.end());
//
//	if (c >= int(data.size()))
//		return "invalid corruption index";
//
//	if (c >= 0)
//		data[c] = 1-data[c];
//
//	vector<int> result_source = retrieve(data);
//
//	if (source != result_source)
//		return "wrong source retrieval";
//
//	return string("OK K=")+to_string(attachment.size());
//}
//
//int main() {
//	int T;
//	cin >> T;
//	for (int scenario = 0; scenario < T; scenario++) {
//		string result = run_scenario();
//		cout << "scenario #" << scenario << ": " << result << endl;
//	}
//	return 0;
//}

Compilation message

transfer.cpp: In function 'std::vector<int> retrieve(std::vector<int>)':
transfer.cpp:32:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |  for(int i=n;i<data.size();i++){
      |              ~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 772 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 8 ms 5628 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -