Submission #745782

#TimeUsernameProblemLanguageResultExecution timeMemory
745782vjudge1Fancy Fence (CEOI20_fancyfence)C++14
13 / 100
62 ms3148 KiB
#include <bits/stdc++.h> using namespace std; #define int long long const int MOD = 1e9 +7; int binpow(int a, int b){ int ans = 1; while(b != 0){ if(b & 1){ ans = ans * a % MOD; } a = a * a % MOD; b /= 2; } return ans; } signed main() { int n; cin >> n; vector<int> h(n), w(n); int cnt = 0; for(int i = 0; i < n; i++){ cin >> h[i]; } for(int i = 0; i < n; i++){ cin >> w[i]; } int dv = binpow(2, MOD - 2); int egy = 0, ketto = 0; int ans = 0; for(int i = 0; i < n; i++){ int act1, bn1, bn2; egy = (egy + w[i]) % MOD; if(h[i] == 1){ ans = ans + (ketto * (ketto + 1) % MOD) % MOD; ketto = 0; } else{ ketto = (ketto + w[i]) % MOD; } } ans = ans + (ketto * (ketto + 1) % MOD) % MOD; ans = (ans + (egy * (egy + 1) % MOD) * dv) % MOD; cout << ans << endl; return 0; }

Compilation message (stderr)

fancyfence.cpp: In function 'int main()':
fancyfence.cpp:35:13: warning: unused variable 'act1' [-Wunused-variable]
   35 |         int act1, bn1, bn2;
      |             ^~~~
fancyfence.cpp:35:19: warning: unused variable 'bn1' [-Wunused-variable]
   35 |         int act1, bn1, bn2;
      |                   ^~~
fancyfence.cpp:35:24: warning: unused variable 'bn2' [-Wunused-variable]
   35 |         int act1, bn1, bn2;
      |                        ^~~
fancyfence.cpp:24:9: warning: unused variable 'cnt' [-Wunused-variable]
   24 |     int cnt = 0;
      |         ^~~
#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...