Submission #498214

# Submission time Handle Problem Language Result Execution time Memory
498214 2021-12-24T15:43:31 Z sireanu_vlad Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++14
0 / 100
3000 ms 332 KB
#include <iostream>
using namespace std;

int mod = 1e9 + 7;
int n, a[1001], q, res, s[100001][3];

void read()
{
	cin >> n;
	for(int i = 1; i <= n; ++i)
		cin >> a[i];
	cin >> q;
	for(int i = 1; i <= q; ++i)
		cin >> s[i][1] >> s[i][2] >> s[i][3];
}

void sum()
{
	for(int i = 1; i <= n; ++i)
		for(int j = i, p; j <= n; ++j)
		{
			p = 0;
			for(int k = i; k <= j; ++k)
				p = (p + a[k]) % mod;
			res = (res + (p*p%mod)) % mod;
		}
}

void up(int l, int r, int x)
{
	for(int i = l; i <= r; ++i)
		a[i] ^= x;
}

void back(int k)
{
	if(k == 0)
		sum();
	if(k > 0)
	{
		up(s[k][1], s[k][2], s[k][3]);
		back(k - 1);
		up(s[k][1], s[k][2], s[k][3]);
		back(k - 1);
	}
}

int main()
{
	read();
	back(q);
	cout << res;
	return 0;
}

Compilation message

sortbooks.cpp: In function 'void back(int)':
sortbooks.cpp:41:5: warning: array subscript 3 is above array bounds of 'int [3]' [-Warray-bounds]
   41 |   up(s[k][1], s[k][2], s[k][3]);
      |   ~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
sortbooks.cpp:43:5: warning: array subscript 3 is above array bounds of 'int [3]' [-Warray-bounds]
   43 |   up(s[k][1], s[k][2], s[k][3]);
      |   ~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 332 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3076 ms 204 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -