답안 #257288

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
257288 2020-08-04T04:27:57 Z BThero Intergalactic ship (IZhO19_xorsum) C++17
9 / 100
2000 ms 384 KB
// chrono::system_clock::now().time_since_epoch().count()
#include<bits/stdc++.h>

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << " = " << x << endl;

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

const int MAXN = (int)1e3 + 5;
const int MOD = (int)1e9 + 7;

array<int, 3> que[MAXN];
int arr[MAXN];
int n, q, ans;

int addMod(int a, int b, int m = MOD) {
  a += b;
  
  if (m <= a) {
    a -= m;
  }
  
  return a;
}

int mulMod(int a, int b, int m = MOD) {
  return a * 1ll * b % m;
}

bool bit(int x, int p) {
  return x & (1 << p);
}

void solve() {
  scanf("%d", &n);
  
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &arr[i]);
  }
  
  scanf("%d", &q);
  
  for (int i = 1; i <= q; ++i) {
    int l, r, x;
    scanf("%d %d %d", &l, &r, &x);
    que[i] = {l, r, x};
  }
  
  for (int mask = 0; mask < (1 << q); ++mask) {
    vector<int> vec(n + 1);
    
    for (int i = 1; i <= n; ++i) {
      vec[i] = arr[i];
    }
    
    for (int i = 1; i <= q; ++i) {
      if (bit(mask, i - 1)) {
        auto &[l, r, x] = que[i];
        
        for (int j = l; j <= r; ++j) {
          vec[j] ^= x;
        }
      }
    }
    
    for (int l = 1; l <= n; ++l) {
      int sum = 0;
      
      for (int r = l; r <= n; ++r) {
        sum = addMod(sum, vec[r]);
        ans = addMod(ans, mulMod(sum, sum));
      }
    }
  }
  
  printf("%d\n", ans);
}

int main() {
  int tt = 1;
  
  while (tt--) {
    solve();
  }

  return 0;
}

Compilation message

xorsum.cpp: In function 'void solve()':
xorsum.cpp:43:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &n);
   ~~~~~^~~~~~~~~~
xorsum.cpp:46:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &arr[i]);
     ~~~~~^~~~~~~~~~~~~~~
xorsum.cpp:49:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &q);
   ~~~~~^~~~~~~~~~
xorsum.cpp:53:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d %d", &l, &r, &x);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 20 ms 384 KB Output is correct
7 Correct 21 ms 384 KB Output is correct
8 Correct 24 ms 368 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1 ms 384 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2083 ms 384 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2077 ms 376 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2077 ms 376 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 20 ms 384 KB Output is correct
7 Correct 21 ms 384 KB Output is correct
8 Correct 24 ms 368 KB Output is correct
9 Execution timed out 2077 ms 376 KB Time limit exceeded
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 20 ms 384 KB Output is correct
7 Correct 21 ms 384 KB Output is correct
8 Correct 24 ms 368 KB Output is correct
9 Execution timed out 2077 ms 376 KB Time limit exceeded
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 20 ms 384 KB Output is correct
7 Correct 21 ms 384 KB Output is correct
8 Correct 24 ms 368 KB Output is correct
9 Execution timed out 1 ms 384 KB Time limit exceeded (wall clock)
10 Halted 0 ms 0 KB -