답안 #308005

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
308005 2020-09-29T18:00:42 Z urd05 Data Transfer (IOI19_transfer) C++14
100 / 100
191 ms 2880 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<6;i++) {
	        ret.push_back(val%2);
	        val/=2;
	    }
	}
	else {
	    for(int i=0;i<8;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()==70) {
	    int x=0;
	    int xval=0;
	    for(int i=63;i<70;i++) {
	        x^=data[i];
	        if (i!=69)
	            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;
	        }
	    }
	    for(int i=0;i<63;i++) {
	        if ((val^(i+1))==xval) {
	            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<264;i++) {
	        x^=data[i];
	        if (i!=263)
	            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;
	        }
	    }
	    for(int i=0;i<255;i++) {
	        if ((val^(i+1))==xval) {
	            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++) {
      |              ~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 1148 KB Output is correct
2 Correct 6 ms 908 KB Output is correct
3 Correct 6 ms 1036 KB Output is correct
4 Correct 6 ms 1036 KB Output is correct
5 Correct 6 ms 1152 KB Output is correct
6 Correct 6 ms 1152 KB Output is correct
7 Correct 6 ms 908 KB Output is correct
8 Correct 7 ms 908 KB Output is correct
9 Correct 6 ms 1140 KB Output is correct
10 Correct 6 ms 1268 KB Output is correct
11 Correct 6 ms 1148 KB Output is correct
12 Correct 6 ms 1068 KB Output is correct
13 Correct 6 ms 1144 KB Output is correct
14 Correct 6 ms 1036 KB Output is correct
15 Correct 7 ms 1144 KB Output is correct
16 Correct 6 ms 908 KB Output is correct
17 Correct 6 ms 1036 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 177 ms 2656 KB Output is correct
2 Correct 179 ms 2624 KB Output is correct
3 Correct 180 ms 2624 KB Output is correct
4 Correct 187 ms 2680 KB Output is correct
5 Correct 191 ms 2804 KB Output is correct
6 Correct 190 ms 2668 KB Output is correct
7 Correct 183 ms 2496 KB Output is correct
8 Correct 182 ms 2684 KB Output is correct
9 Correct 172 ms 2676 KB Output is correct
10 Correct 174 ms 2624 KB Output is correct
11 Correct 172 ms 2880 KB Output is correct
12 Correct 176 ms 2800 KB Output is correct
13 Correct 176 ms 2624 KB Output is correct
14 Correct 176 ms 2676 KB Output is correct
15 Correct 179 ms 2672 KB Output is correct
16 Correct 182 ms 2668 KB Output is correct
17 Correct 178 ms 2680 KB Output is correct
18 Correct 176 ms 2520 KB Output is correct
19 Correct 180 ms 2676 KB Output is correct