Submission #1107004

#TimeUsernameProblemLanguageResultExecution timeMemory
1107004vjudge1Flooding Wall (BOI24_wall)C++17
8 / 100
129 ms6864 KiB
#include<bits/stdc++.h> #define fori(i,a,b) for(int i=a;i<=b;i++) #define int long long #define pb push_back using namespace std; typedef pair<int,int> ii; typedef tuple<int,int,int> tp; const int M=1e6+10; const int N=1e3+10; const int mod=1e9+7; int n,a[M],b[M]; int x[M],y[M],kq=0; void ktra() { fori(i,1,n) y[i]=1e9; int l=0,r=0; fori(i,1,n) { l=max(l,x[i]); y[i]=min(y[i],l); } for(int i=n;i!=0;i--) { r=max(r,x[i]); y[i]=min(y[i],r); } fori(i,1,n) kq=(kq+max(0ll,y[i]-x[i]))%mod; } void duyet(int i) { if(i==n+1) ktra(); else { fori(j,0,1) { if(j) x[i]=a[i]; else x[i]=b[i]; duyet(i+1); } } } int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); if(fopen("1.inp","r")) { freopen("1.inp","r",stdin); freopen("1.out","w",stdout); } #define task "" if(fopen(task".inp","r")) { freopen(task".inp","r",stdin); freopen(task".out","w",stdout); } cin >> n; fori(i,1,n) cin >> a[i]; fori(i,1,n) cin >> b[i]; if(n<=20) { duyet(1); cout << kq ; } }

Compilation message (stderr)

Main.cpp: In function 'int32_t main()':
Main.cpp:46:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   46 |     freopen("1.inp","r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~
Main.cpp:47:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   47 |     freopen("1.out","w",stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~
Main.cpp:52:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   52 |     freopen(task".inp","r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
Main.cpp:53:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   53 |     freopen(task".out","w",stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
#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...