Submission #382243

#TimeUsernameProblemLanguageResultExecution timeMemory
382243BartolMIntergalactic ship (IZhO19_xorsum)C++17
9 / 100
2080 ms3164 KiB
#include <bits/stdc++.h> using namespace std; #define X first #define Y second #define mp make_pair #define pb push_back typedef long long ll; typedef pair <int, int> pii; typedef pair <int, pii> pip; typedef pair <pii, int> ppi; typedef pair <ll, ll> pll; const int INF=0x3f3f3f3f; const int LOG=7; const int N=1005; const int MOD=1e9+7; const int Q=1e5+5; int add(int a, int b) { a+=b; if (a>=MOD) a-=MOD; return a; } int mul(int a, int b) { return (ll)a*b%MOD; } int n, q; int p[N], np[N]; vector <ppi> que; #define DEBUG 0 void solve() { int sol=0; for (int mask=0; mask<(1<<q); ++mask) { for (int i=0; i<n; ++i) np[i]=p[i]; for (int i=0; i<q; ++i) { if ((1<<i) & mask) { for (int j=que[i].X.X; j<=que[i].X.Y; ++j) np[j]=np[j]^que[i].Y; } } for (int i=0; i<n; ++i) { for (int j=i; j<n; ++j) { int interi=mul(i+1, n-j); if (i!=j) interi=mul(interi, 2); int curr=mul(np[i], np[j]); sol=add(sol, mul(curr, interi)); } } } printf("%d\n", sol); } void load() { scanf("%d", &n); for (int i=0; i<n; ++i) scanf("%d", p+i); scanf("%d", &q); for (int i=0; i<q; ++i) { int l, r, x; scanf("%d %d %d", &l, &r, &x); l--; r--; que.pb(mp(mp(l, r), x)); } } int main() { load(); assert(q<=20); // pot[0]=1; // for (int i=1; i<=q; ++i) pot[i]=mul(pot[i-1], 2); solve(); return 0; }

Compilation message (stderr)

xorsum.cpp: In function 'void load()':
xorsum.cpp:60:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   60 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
xorsum.cpp:61:34: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   61 |     for (int i=0; i<n; ++i) scanf("%d", p+i);
      |                             ~~~~~^~~~~~~~~~~
xorsum.cpp:62:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   62 |     scanf("%d", &q);
      |     ~~~~~^~~~~~~~~~
xorsum.cpp:65:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   65 |         scanf("%d %d %d", &l, &r, &x); l--; r--;
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...