Submission #382021

# Submission time Handle Problem Language Result Execution time Memory
382021 2021-03-26T09:48:59 Z vanic Red-blue table (IZhO19_stones) C++14
0 / 100
188 ms 492 KB
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <cassert>
#include <bitset>

using namespace std;

typedef long long ll;

const int maxn=105, mod=1e9+7, maxq=22;

inline int sum(int a, int b){
	if(a+b>=mod){
		return a+b-mod;
	}
	if(a+b<0){
		return a+b+mod;
	}
	return a+b;
}

inline int mul(int a, int b){
	return (ll)a*b%mod;
}

int n, m;
int a[maxn];
int sol;
int q[maxq][3];
bitset < maxq > ocu;
int pravi[maxn];

void probaj(){
	for(int i=0; i<n; i++){
		pravi[i]=a[i];
	}
	for(int i=0; i<m; i++){
		if(ocu[i]){
			for(int j=q[i][0]; j<=q[i][1]; j++){
				pravi[j]^=q[i][2];
			}
		}
	}
	int kofa;
	for(int i=0; i<n; i++){
		for(int j=i; j<n; j++){
			if(j!=i){
				kofa=2*(i+1)*(n-j);
			}
			else{
				kofa=(i+1)*(n-j);
			}
			sol=sum(sol, mul(kofa, mul(pravi[i], pravi[j])));
		}
	}
}

void rek(int x){
	if(x==m){
		probaj();
		return;
	}
	ocu[x]=0;
	rek(x+1);
	ocu[x]=1;
	rek(x+1);
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin >> n;
	for(int i=0; i<n; i++){
		cin >> a[i];
	}
	cin >> m;
	assert(m<maxq);
	for(int i=0; i<m; i++){
		cin >> q[i][0] >> q[i][1] >> q[i][2];
		q[i][0]--;
		q[i][1]--;
	}
	rek(0);
	cout << sol <<  '\n';
	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Unexpected end of file - token expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Unexpected end of file - token expected
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Unexpected end of file - token expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 188 ms 396 KB Unexpected end of file - token expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 492 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Unexpected end of file - token expected
2 Halted 0 ms 0 KB -