Submission #218344

# Submission time Handle Problem Language Result Execution time Memory
218344 2020-04-02T03:45:19 Z Lawliet Intergalactic ship (IZhO19_xorsum) C++17
17 / 100
2000 ms 1536 KB
#include <bits/stdc++.h>

using namespace std;
typedef long long int lli;

const int MAXN = 1010;
const int MAXQ = 100010;
const int MOD = 1000000007;

int n, q;

int v[MAXN];
int L[MAXQ];
int R[MAXQ];
int X[MAXQ];
int aux[MAXQ];

void mod(lli& k) { if( k >= MOD ) k -= MOD; }

int main()
{
	scanf("%d",&n);

	for(int i = 1 ; i <= n ; i++)
		scanf("%d",&v[i]);

	scanf("%d",&q);

	for(int i = 0 ; i < q ; i++)
		scanf("%d %d %d",&L[i],&R[i],&X[i]);

	lli ans = 0;

	for(int mask = 0 ; mask < (1 << q) ; mask++)
	{
		for(int i = 1 ; i <= n ; i++)
			aux[i] = 0;

		for(int i = 0 ; i < q ; i++)
		{
			if( mask & (1 << i) )
			{
				aux[ L[i] ] ^= X[i];
				aux[ R[i] + 1 ] ^= X[i];
			}
		}

		int curXor = 0;

		lli sumAcc = 0;
		lli sumAll = 0;

		for(int i = 1 ; i <= n ; i++)
		{
			curXor ^= aux[i];
			int curV = v[i]^curXor;

			sumAll += 2*sumAcc*curV;
			sumAll %= MOD;

			sumAll += curV*curV*i;
			mod( sumAll );

			ans += sumAll;
			mod( ans );

			sumAcc += curV*i;
			mod( sumAcc );
		}
	}	

	printf("%lld\n",ans);
}

Compilation message

xorsum.cpp: In function 'int main()':
xorsum.cpp:22:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
  ~~~~~^~~~~~~~~
xorsum.cpp:25:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&v[i]);
   ~~~~~^~~~~~~~~~~~
xorsum.cpp:27:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&q);
  ~~~~~^~~~~~~~~
xorsum.cpp:30:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d %d",&L[i],&R[i],&X[i]);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 256 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 256 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 6 ms 512 KB Output is correct
7 Correct 6 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 33 ms 1536 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2095 ms 384 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 324 ms 376 KB Output is correct
2 Correct 320 ms 384 KB Output is correct
3 Correct 338 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 324 ms 376 KB Output is correct
2 Correct 320 ms 384 KB Output is correct
3 Correct 338 ms 384 KB Output is correct
4 Incorrect 8 ms 512 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 256 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 6 ms 512 KB Output is correct
7 Correct 6 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 324 ms 376 KB Output is correct
10 Correct 320 ms 384 KB Output is correct
11 Correct 338 ms 384 KB Output is correct
12 Incorrect 10 ms 384 KB Output isn't correct
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 256 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 6 ms 512 KB Output is correct
7 Correct 6 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 324 ms 376 KB Output is correct
10 Correct 320 ms 384 KB Output is correct
11 Correct 338 ms 384 KB Output is correct
12 Incorrect 8 ms 512 KB Output isn't correct
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 256 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 6 ms 512 KB Output is correct
7 Correct 6 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Incorrect 33 ms 1536 KB Output isn't correct
10 Halted 0 ms 0 KB -