Submission #218342

# Submission time Handle Problem Language Result Execution time Memory
218342 2020-04-02T03:42:31 Z Lawliet Intergalactic ship (IZhO19_xorsum) C++17
9 / 100
2000 ms 2296 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 < mask ; 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 384 KB Output is correct
3 Correct 6 ms 384 KB Output is correct
4 Correct 6 ms 384 KB Output is correct
5 Correct 6 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 384 KB Output is correct
3 Correct 6 ms 384 KB Output is correct
4 Correct 6 ms 384 KB Output is correct
5 Correct 6 ms 384 KB Output is correct
6 Correct 6 ms 384 KB Output is correct
7 Correct 6 ms 384 KB Output is correct
8 Correct 8 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 44 ms 2296 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2085 ms 384 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2033 ms 384 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2033 ms 384 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 6 ms 384 KB Output is correct
4 Correct 6 ms 384 KB Output is correct
5 Correct 6 ms 384 KB Output is correct
6 Correct 6 ms 384 KB Output is correct
7 Correct 6 ms 384 KB Output is correct
8 Correct 8 ms 384 KB Output is correct
9 Execution timed out 2033 ms 384 KB Time limit exceeded
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 6 ms 384 KB Output is correct
4 Correct 6 ms 384 KB Output is correct
5 Correct 6 ms 384 KB Output is correct
6 Correct 6 ms 384 KB Output is correct
7 Correct 6 ms 384 KB Output is correct
8 Correct 8 ms 384 KB Output is correct
9 Execution timed out 2033 ms 384 KB Time limit exceeded
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 6 ms 384 KB Output is correct
4 Correct 6 ms 384 KB Output is correct
5 Correct 6 ms 384 KB Output is correct
6 Correct 6 ms 384 KB Output is correct
7 Correct 6 ms 384 KB Output is correct
8 Correct 8 ms 384 KB Output is correct
9 Incorrect 44 ms 2296 KB Output isn't correct
10 Halted 0 ms 0 KB -