Submission #307949

# Submission time Handle Problem Language Result Execution time Memory
307949 2020-09-29T16:07:08 Z urd05 Data Transfer (IOI19_transfer) C++14
80 / 100
205 ms 2796 KB
#include "transfer.h"
#include <bits/stdc++.h>
using namespace std;

vector<int> get_attachment(vector<int> source) {
	int n=source.size();
	int val=0;
	for(int i=0;i<n;i++) {
	    if (source[i]==1) {
	        val+=i+1;
	        val%=2*(n+1);
	    }
	}
	vector<int> ret;
	if (n==63) {
	    for(int i=0;i<7;i++) {
	        ret.push_back(val%2);
	        val/=2;
	    }
	}
	else {
	    for(int i=0;i<9;i++) {
	        ret.push_back(val%2);
	        val/=2;
	    }
	}
	int x=0;
	for(int i=0;i<ret.size();i++) {
	    x^=ret[i];
	}
	ret.push_back(x);
	return ret;
}

vector<int> retrieve(vector<int> data) {
    vector<int> ret;
	if (data.size()==71) {
	    int x=0;
	    int xval=0;
	    for(int i=63;i<71;i++) {
	        x^=data[i];
	        if (i!=70)
	            xval+=(data[i]<<(i-63));
	    }
	    if (x==1) {
	        for(int i=0;i<63;i++) {
	            ret.push_back(data[i]);
	        }
	        return ret;
	    }
	    int pos=-1;
	    int val=0;
	    for(int i=0;i<63;i++) {
	        if (data[i]==1) {
	            val+=i+1;
	            val%=128;
	        }
	    }
	    for(int i=0;i<63;i++) {
	        if (data[i]==0) {
	            if ((val+i+1)%128==xval) {
	                pos=i;
	                break;
	            }
	        }
	        else {
	            if ((xval+i+1)%128==val) {
	                pos=i;
	                break;
	            }
	        }
	    }
	    for(int i=0;i<63;i++) {
	        ret.push_back(data[i]^(pos==i));
	    }
	}
	else {
	    int x=0;
	    int xval=0;
	    for(int i=255;i<265;i++) {
	        x^=data[i];
	        if (i!=264)
	            xval+=(data[i]<<(i-255));
	    }
	    if (x==1) {
	        for(int i=0;i<255;i++) {
	            ret.push_back(data[i]);
	        }
	        return ret;
	    }
	    int pos=-1;
	    int val=0;
	    for(int i=0;i<255;i++) {
	        if (data[i]==1) {
	            val+=i+1;
	            val%=512;
	        }
	    }
	    for(int i=0;i<255;i++) {
	        if (data[i]==0) {
	            if ((val+i+1)%512==xval) {
	                pos=i;
	                break;
	            }
	        }
	        else {
	            if ((xval+i+1)%512==val) {
	                pos=i;
	                break;
	            }
	        }
	    }
	    for(int i=0;i<255;i++) {
	        ret.push_back(data[i]^(pos==i));
	    }
	}
	return ret;
}

Compilation message

transfer.cpp: In function 'std::vector<int> get_attachment(std::vector<int>)':
transfer.cpp:28:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |  for(int i=0;i<ret.size();i++) {
      |              ~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Partially correct 6 ms 1144 KB Partially correct
2 Partially correct 6 ms 1036 KB Partially correct
3 Partially correct 6 ms 908 KB Partially correct
4 Partially correct 7 ms 908 KB Partially correct
5 Partially correct 7 ms 1040 KB Partially correct
6 Partially correct 7 ms 1524 KB Partially correct
7 Partially correct 7 ms 908 KB Partially correct
8 Partially correct 6 ms 908 KB Partially correct
9 Partially correct 6 ms 1144 KB Partially correct
10 Partially correct 6 ms 924 KB Partially correct
11 Partially correct 7 ms 1036 KB Partially correct
12 Partially correct 6 ms 908 KB Partially correct
13 Partially correct 6 ms 1036 KB Partially correct
14 Partially correct 8 ms 908 KB Partially correct
15 Partially correct 6 ms 1036 KB Partially correct
16 Partially correct 6 ms 1148 KB Partially correct
17 Partially correct 6 ms 1036 KB Partially correct
# Verdict Execution time Memory Grader output
1 Partially correct 187 ms 2684 KB Partially correct
2 Partially correct 186 ms 2676 KB Partially correct
3 Partially correct 187 ms 2624 KB Partially correct
4 Partially correct 192 ms 2624 KB Partially correct
5 Partially correct 205 ms 2796 KB Partially correct
6 Partially correct 203 ms 2676 KB Partially correct
7 Partially correct 200 ms 2668 KB Partially correct
8 Partially correct 201 ms 2668 KB Partially correct
9 Partially correct 186 ms 2660 KB Partially correct
10 Partially correct 192 ms 2624 KB Partially correct
11 Partially correct 185 ms 2672 KB Partially correct
12 Partially correct 186 ms 2624 KB Partially correct
13 Partially correct 187 ms 2684 KB Partially correct
14 Partially correct 186 ms 2668 KB Partially correct
15 Partially correct 188 ms 2672 KB Partially correct
16 Partially correct 190 ms 2624 KB Partially correct
17 Partially correct 192 ms 2672 KB Partially correct
18 Partially correct 188 ms 2676 KB Partially correct
19 Partially correct 188 ms 2672 KB Partially correct