Submission #690576

# Submission time Handle Problem Language Result Execution time Memory
690576 2023-01-30T09:55:44 Z iskhakkutbilim Intergalactic ship (IZhO19_xorsum) C++14
17 / 100
2000 ms 3424 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
const int N = 1000;
const int M = 1e9+7;

struct upd{
	int l, r, x;
};
vector<upd> query;
int n, q, a[N];
int count_K(){
	int sum = 0;
	for(int i = 0;i < n; i++){
		int s = 0;
		for(int j = i;j < n; j++){
			s+= a[j];
			sum = (sum + s*s)%M;
		}
	}
	return sum;
}

main(){
   ios::sync_with_stdio(0);
   cin.tie(0); cout.tie(0);
	cin >> n;
	for(int i = 0;i < n; i++){
		cin >> a[i];
	}
	cin >> q;
	query.resize(q);
	for(int i = 0;i < q; i++){
		cin >> query[i].l >> query[i].r >> query[i].x;
		query[i].l--, query[i].r--;
	}
	int answer = 0;
	for(int mask = 0; mask < (1<<q); mask++){
		for(int i = 0;i < q; i++){
			if(mask & (1<<i)){
				for(int j = query[i].l; j <= query[i].r; j++){
					a[j] = (a[j] ^ query[i].x);
				}
			}
		}
		answer = (answer + count_K())%M;
		for(int i = 0;i < q; i++){
			if(mask & (1<<i)){
				for(int j = query[i].l; j <= query[i].r; j++){
					a[j] = (a[j] ^ query[i].x);
				}
			}
		}
	}
	cout << answer;
	return 0;
}

Compilation message

xorsum.cpp:28:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   28 | main(){
      | ^~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 18 ms 328 KB Output is correct
7 Correct 17 ms 212 KB Output is correct
8 Correct 19 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 20 ms 3424 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2077 ms 340 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1851 ms 304 KB Output is correct
2 Correct 1867 ms 304 KB Output is correct
3 Correct 1814 ms 304 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1851 ms 304 KB Output is correct
2 Correct 1867 ms 304 KB Output is correct
3 Correct 1814 ms 304 KB Output is correct
4 Incorrect 10 ms 468 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 18 ms 328 KB Output is correct
7 Correct 17 ms 212 KB Output is correct
8 Correct 19 ms 212 KB Output is correct
9 Correct 1851 ms 304 KB Output is correct
10 Correct 1867 ms 304 KB Output is correct
11 Correct 1814 ms 304 KB Output is correct
12 Incorrect 88 ms 328 KB Output isn't correct
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 18 ms 328 KB Output is correct
7 Correct 17 ms 212 KB Output is correct
8 Correct 19 ms 212 KB Output is correct
9 Correct 1851 ms 304 KB Output is correct
10 Correct 1867 ms 304 KB Output is correct
11 Correct 1814 ms 304 KB Output is correct
12 Incorrect 10 ms 468 KB Output isn't correct
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 18 ms 328 KB Output is correct
7 Correct 17 ms 212 KB Output is correct
8 Correct 19 ms 212 KB Output is correct
9 Incorrect 20 ms 3424 KB Output isn't correct
10 Halted 0 ms 0 KB -