Submission #829872

# Submission time Handle Problem Language Result Execution time Memory
829872 2023-08-18T15:29:14 Z Essa2006 Data Transfer (IOI19_transfer) C++14
0 / 100
5 ms 2448 KB
#include "transfer.h"
#include<bits/stdc++.h>

using namespace std;

vector<int> get_attachment(vector<int> source) {
    vector<int>Ans;
	for(int j=0;j<=9;j++){
        int cur=(1<<j);
        int res=0;
        bool cont=0;
        for(int i=0;i<source.size();i++){
            if(i&cur){
                cont=1;
                res^=source[i];
            }
        }
        if(!cont)
            continue;
        Ans.push_back(res);
	}
	Ans.push_back(source.front());
	int res=0;
	for(int i=0;i<Ans.size();i++){
        res^=Ans[i];
	}
	Ans.push_back(res);
	return Ans;
}

vector<int> retrieve(vector<int> data) {
	int ind=0;
	int n=15;
	if(data.size()>200){
        n=255;
	}
	vector<int>Cur(n);
	for(int j=0;j<=9;j++){
        int cur=(1<<j);
        int res=0;
        bool cont=0;
        for(int i=0;i<n;i++){
            if(i&cur){
                cont=1;
                res^=data[i];
            }
        }
        if(!cont)
            continue;
        Cur.push_back(res);
	}
	int res=0;
	for(int i=n;i<data.size()-2;i++){
        res^=data[i];
        if(Cur[i]!=data[i]){
            ind+=(1<<(i-n));
        }
	}
	res^=data[data.size()-2];
	vector<int>Ans;
	for(int i=0;i<n;i++){
        Ans.push_back(data[i]);
	}
	if(ind && res!=data.back()){
        ind=0;
	}
	if(ind || (ind==0 && data[data.size()-2]!=Ans.front())){
        Ans[ind]=!Ans[ind];
	}
	if(Ans.size()!=n)
        n/=0;
	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> get_attachment(std::vector<int>)':
transfer.cpp:12:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |         for(int i=0;i<source.size();i++){
      |                     ~^~~~~~~~~~~~~~
transfer.cpp:24:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |  for(int i=0;i<Ans.size();i++){
      |              ~^~~~~~~~~~~
transfer.cpp: In function 'std::vector<int> retrieve(std::vector<int>)':
transfer.cpp:53:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   53 |  for(int i=n;i<data.size()-2;i++){
      |              ~^~~~~~~~~~~~~~
transfer.cpp:70:15: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   70 |  if(Ans.size()!=n)
      |     ~~~~~~~~~~^~~
transfer.cpp:71:10: warning: division by zero [-Wdiv-by-zero]
   71 |         n/=0;
      |         ~^~~
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 900 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 2448 KB WA in grader: wrong source retrieval
2 Halted 0 ms 0 KB -