답안 #1037342

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1037342 2024-07-28T14:21:46 Z Alfraganus Intergalactic ship (IZhO19_xorsum) C++17
0 / 100
2000 ms 8220 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define str string
#define fastio ios::sync_with_stdio(0), cin.tie(0);
#define fs first
#define ss second
#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define len(x) x.size()

#define print(a)          \
    for (auto &x : a)     \
        cout << x << " "; \
    cout << endl;

#define printmp(a)    \
    for (auto &x : a) \
        cout << x.fs << " " << x.ss << endl;

const int mod = 1e9 + 7;

vector<int> a;
vector<array<int, 3>> S;
int ans = 0;

void dfs(int p){
    for(int i = 0; i < a.size(); i ++){
        int sum = 0;
        for(int j = i; j < a.size(); j ++){
            sum += a[j];
            sum %= mod;
            ans = (ans + sum * sum) % mod;
        }
    }
    for(int j = p; j < S.size(); j ++){
        for(int x = S[p][0] - 1; x < S[p][1]; x ++)
            a[x] ^= S[p][2];
        dfs(j + 1);
        for(int x = S[p][0] - 1; x < S[p][1]; x ++)
            a[x] ^= S[p][2];
    }
}

void solve(){
    int n;
    cin >> n;
    a.resize(n);
    for(int i = 0; i < n; i ++)
        cin >> a[i];
    int q;
    cin >> q;
    S.resize(q);
    for(int i = 0; i < q; i ++)
        cin >> S[i][0] >> S[i][1] >> S[i][2];
    dfs(0);
    cout << ans;
}

signed main()
{
    fastio;
    #ifdef Javohir
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int t = 1;
    // cin >> t;
    while (t--)
    {
        solve();
        cout << endl;
    }
}

Compilation message

xorsum.cpp: In function 'void dfs(long long int)':
xorsum.cpp:29:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |     for(int i = 0; i < a.size(); i ++){
      |                    ~~^~~~~~~~~~
xorsum.cpp:31:26: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |         for(int j = i; j < a.size(); j ++){
      |                        ~~^~~~~~~~~~
xorsum.cpp:37:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::array<long long int, 3> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |     for(int j = p; j < S.size(); j ++){
      |                    ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 460 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 460 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2041 ms 8220 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2032 ms 460 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1799 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1799 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 460 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 460 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 460 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -