Submission #308248

# Submission time Handle Problem Language Result Execution time Memory
308248 2020-09-30T13:21:20 Z cheetose Data Transfer (IOI19_transfer) C++17
100 / 100
81 ms 2808 KB
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define y0 y12
#define y1 y22
#define INF 987654321
#define PI 3.141592653589793238462643383279502884
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset((a),0,sizeof(a));
#define MEM_1(a) memset((a),-1,sizeof(a));
#define ALL(a) a.begin(),a.end()
#define SYNC ios_base::sync_with_stdio(false);cin.tie(0)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef double db;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<ld, ld> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<db> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef tuple<int, int, int> iii;
typedef tuple<int, int, int, int> iiii;
typedef tuple<ll, ll, ll> LLL;
typedef vector<iii> Viii;
typedef vector<LLL> VLLL;
typedef complex<double> base;
const int MOD = 1000000007;
ll POW(ll a, ll b, ll MMM = MOD) { ll ret = 1; for (; b; b >>= 1, a = (a*a) % MMM)if (b & 1)ret = (ret*a) % MMM; return ret; }
int dx[] = { 0,1,0,-1,1,1,-1,-1 }, dy[] = { 1,0,-1,0,1,-1,1,-1 };
int ddx[] = { -1,-2,1,-2,2,-1,2,1 }, ddy[] = { -2,-1,-2,1,-1,2,1,2 };

#include "transfer.h"
Vi get_attachment(Vi source){
	int n=source.size();
	Vi res;
	int t=0;
	if(n==63){
		res.resize(7);
		fup(i,1,63,1){
			if(source[i-1])t^=i;
		}
		fup(i,0,5,1){
			if(t&(1<<i)){
				res[i]=1;
				res[6]^=1;
			}
		}
	}else{
		res.resize(9);
		fup(i,1,255,1){
			if(source[i-1])t^=i;
		}
		fup(i,0,7,1){
			if(t&(1<<i)){
				res[i]=1;
				res[8]^=1;
			}
		}
	}
	return res;
}
Vi retrieve(Vi data){
	int n=data.size();
	if(n>200){
		Vi v(9);
		fup(i,255,263,1)v[i-255]=data[i];
		data.resize(255);
		int c=0;
		fup(i,0,8,1)c^=v[i];
		if(c!=0){
			return data;
		}else{
			fup(i,0,7,1){
				if(v[i])c^=(1<<i);
			}
			fup(i,1,255,1)if(data[i-1])c^=i;
			if(c!=0)data[c-1]^=1;
			return data;
		}
	}else{
		Vi v(7);
		fup(i,63,69,1)v[i-63]=data[i];
		data.resize(63);
		int c=0;
		fup(i,0,6,1)c^=v[i];
		if(c!=0){
			return data;
		}else{
			fup(i,0,5,1){
				if(v[i])c^=(1<<i);
			}
			fup(i,1,63,1)if(data[i-1])c^=i;
			if(c!=0)data[c-1]^=1;
			return data;
		}
	}
}
/*
int main() {

}*/

Compilation message

transfer.cpp: In function 'Vi get_attachment(Vi)':
transfer.cpp:10:30: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   10 | #define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
      |                              ^
transfer.cpp:49:3: note: in expansion of macro 'fup'
   49 |   fup(i,1,63,1){
      |   ^~~
transfer.cpp:10:30: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   10 | #define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
      |                              ^
transfer.cpp:52:3: note: in expansion of macro 'fup'
   52 |   fup(i,0,5,1){
      |   ^~~
transfer.cpp:10:30: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   10 | #define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
      |                              ^
transfer.cpp:60:3: note: in expansion of macro 'fup'
   60 |   fup(i,1,255,1){
      |   ^~~
transfer.cpp:10:30: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   10 | #define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
      |                              ^
transfer.cpp:63:3: note: in expansion of macro 'fup'
   63 |   fup(i,0,7,1){
      |   ^~~
transfer.cpp: In function 'Vi retrieve(Vi)':
transfer.cpp:10:30: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   10 | #define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
      |                              ^
transfer.cpp:76:3: note: in expansion of macro 'fup'
   76 |   fup(i,255,263,1)v[i-255]=data[i];
      |   ^~~
transfer.cpp:10:30: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   10 | #define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
      |                              ^
transfer.cpp:79:3: note: in expansion of macro 'fup'
   79 |   fup(i,0,8,1)c^=v[i];
      |   ^~~
transfer.cpp:10:30: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   10 | #define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
      |                              ^
transfer.cpp:83:4: note: in expansion of macro 'fup'
   83 |    fup(i,0,7,1){
      |    ^~~
transfer.cpp:10:30: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   10 | #define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
      |                              ^
transfer.cpp:86:4: note: in expansion of macro 'fup'
   86 |    fup(i,1,255,1)if(data[i-1])c^=i;
      |    ^~~
transfer.cpp:10:30: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   10 | #define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
      |                              ^
transfer.cpp:92:3: note: in expansion of macro 'fup'
   92 |   fup(i,63,69,1)v[i-63]=data[i];
      |   ^~~
transfer.cpp:10:30: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   10 | #define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
      |                              ^
transfer.cpp:95:3: note: in expansion of macro 'fup'
   95 |   fup(i,0,6,1)c^=v[i];
      |   ^~~
transfer.cpp:10:30: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   10 | #define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
      |                              ^
transfer.cpp:99:4: note: in expansion of macro 'fup'
   99 |    fup(i,0,5,1){
      |    ^~~
transfer.cpp:10:30: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   10 | #define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
      |                              ^
transfer.cpp:102:4: note: in expansion of macro 'fup'
  102 |    fup(i,1,63,1)if(data[i-1])c^=i;
      |    ^~~
# Verdict Execution time Memory Grader output
1 Correct 4 ms 1016 KB Output is correct
2 Correct 4 ms 1144 KB Output is correct
3 Correct 4 ms 912 KB Output is correct
4 Correct 4 ms 1144 KB Output is correct
5 Correct 4 ms 1012 KB Output is correct
6 Correct 4 ms 904 KB Output is correct
7 Correct 4 ms 1040 KB Output is correct
8 Correct 4 ms 1156 KB Output is correct
9 Correct 4 ms 1152 KB Output is correct
10 Correct 4 ms 1040 KB Output is correct
11 Correct 4 ms 1144 KB Output is correct
12 Correct 4 ms 1040 KB Output is correct
13 Correct 4 ms 912 KB Output is correct
14 Correct 4 ms 1040 KB Output is correct
15 Correct 4 ms 1040 KB Output is correct
16 Correct 4 ms 1152 KB Output is correct
17 Correct 4 ms 1148 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 76 ms 2692 KB Output is correct
2 Correct 75 ms 2664 KB Output is correct
3 Correct 69 ms 2500 KB Output is correct
4 Correct 76 ms 2664 KB Output is correct
5 Correct 81 ms 2628 KB Output is correct
6 Correct 80 ms 2672 KB Output is correct
7 Correct 76 ms 2500 KB Output is correct
8 Correct 74 ms 2680 KB Output is correct
9 Correct 62 ms 2788 KB Output is correct
10 Correct 66 ms 2676 KB Output is correct
11 Correct 61 ms 2628 KB Output is correct
12 Correct 68 ms 2680 KB Output is correct
13 Correct 72 ms 2672 KB Output is correct
14 Correct 66 ms 2676 KB Output is correct
15 Correct 68 ms 2672 KB Output is correct
16 Correct 68 ms 2664 KB Output is correct
17 Correct 70 ms 2808 KB Output is correct
18 Correct 81 ms 2680 KB Output is correct
19 Correct 67 ms 2628 KB Output is correct