# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1103154 | 2024-10-20T11:03:01 Z | Zero_OP | Intergalactic ship (IZhO19_xorsum) | C++14 | 1 ms | 596 KB |
#include <bits/stdc++.h> using namespace std; #define rep(i, l, r) for(int i = (l), _r = (r); i < _r; ++i) #define FOR(i, l, r) for(int i = (l), _r = (r); i <= _r; ++i) #define ROF(i, r, l) for(int i = (r), _l = (l); i >= _l; --i) #define all(v) begin(v), end(v) #define compact(v) v.erase(unique(all(v)), end(v)) #define sz(v) (int)v.size() #define dbg(x) "[" #x " = " << (x) << "]" template<typename T> bool minimize(T& a, const T& b){ if(a > b) return a = b, true; return false; } template<typename T> bool maximize(T& a, const T& b){ if(a < b) return a = b, true; return false; } using ll = long long; using ld = long double; mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); template<typename T> T random_int(T l, T r){ return uniform_int_distribution<T>(l, r)(rng); } template<typename T> T random_real(T l, T r){ return uniform_real_distribution<T>(l, r)(rng); } const int MAX = 1e3 + 5; const int mod = 1e9 + 7; struct mint{ int v; mint(int v = 0) : v(v) {} mint(ll v = 0) : v(v % mod) {} mint& operator += (const mint& a){ v += a.v; if(v >= mod) v -= mod; return *this; } mint& operator -= (const mint& a){ v -= a.v; if(v < 0) v += mod; return *this; } mint& operator *= (const mint& a){ v = 1LL * v * a.v % mod; return *this; } mint& operator /= (const mint& a){ return (*this) *= a.inv(); } mint power(ll pw) const { mint res(1); mint base = *this; for(; pw > 0; pw /= 2, base *= base){ if(pw & 1) res *= base; } return res; } mint inv() const { return power(mod - 2); } friend mint operator + (mint a, const mint& b){ return a += b; } friend mint operator - (mint a, const mint& b){ return a -= b; } friend mint operator * (mint a, const mint& b){ return a *= b; } friend mint operator / (mint a, const mint& b){ return a /= b; } friend istream& operator >> (istream& in, mint& x){ return in >> x.v; } friend ostream& operator << (ostream& out, const mint& x){ return out << x.v; } #define define_logical_operation(o) friend bool operator o (const mint& a, const mint& b){ return a.v o b.v; } define_logical_operation(==) define_logical_operation(!=) define_logical_operation(<) define_logical_operation(>) define_logical_operation(<=) define_logical_operation(>=) }; int n, q, a[MAX], l[MAX], r[MAX], x[MAX]; namespace subtask_small{ int diff[MAX]; void solve(){ mint ans(0); for(int mask = 0; mask < (1 << q); ++mask){ for(int i = 1; i <= n; ++i) diff[i] = 0; for(int i = 0; i < q; ++i){ if(mask >> i & 1){ diff[l[i + 1]] ^= x[i + 1]; diff[r[i + 1] + 1] ^= x[i + 1]; } } for(int i = 1; i <= n; ++i){ diff[i] ^= diff[i - 1]; a[i] ^= diff[i]; } for(int i = 1; i <= n; ++i){ mint sum = 0; for(int j = i; j <= n; ++j){ sum += mint(a[j]); ans += sum * sum; } } for(int i = 1; i <= n; ++i){ a[i] ^= diff[i]; } } cout << ans << '\n'; } } void testcase(){ cin >> n; for(int i = 1; i <= n; ++i){ cin >> a[i]; } cin >> q; for(int i = 1; i <= q; ++i){ cin >> l[i] >> r[i] >> x[i]; } if(n <= 10 && q <= 10) subtask_small::solve(); } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); #define filename "task" if(fopen(filename".inp", "r")){ freopen(filename".inp", "r", stdin); freopen(filename".out", "w", stdout); } int T = 1; //cin >> T; while(T--) testcase(); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 1 ms | 504 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 1 ms | 504 KB | Output is correct |
6 | Incorrect | 1 ms | 504 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 596 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 504 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 340 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 340 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 1 ms | 504 KB | Output is correct |
6 | Incorrect | 1 ms | 504 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 1 ms | 504 KB | Output is correct |
6 | Incorrect | 1 ms | 504 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 1 ms | 504 KB | Output is correct |
6 | Incorrect | 1 ms | 504 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |