제출 #1033578

#제출 시각아이디문제언어결과실행 시간메모리
1033578BuiDucManh123Trains (BOI24_trains)C++14
21 / 100
2062 ms3208 KiB
#include <bits/stdc++.h> #define fi first #define se second #define ll long long #define ull unsigned long long #define pii pair<int, int> #define pll pair<ll, ll> #define pb push_back #define taskname "" using namespace std; const int mod=1e9+7; ll n,i,a[100009],d[100009],x[100009],bit[100009],f[100009],j,ans; bool check; void update(int id,int val){ while(id<=n){ bit[id]+=val; bit[id]%=mod; id+=id&-id; } } ll get(int id){ ll res=0; while(id){ res+=bit[id]; res%=mod; id-=id&-id; }return res; } int main() { if (fopen(taskname".inp","r")) { freopen(taskname".inp","r",stdin); freopen(taskname".out","w",stdout); } ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin>>n;check=true; for(i=1;i<=n;i++){ cin>>d[i]>>x[i]; if(d[i]!=1) check=false; } if(check==false){ f[1]=1; for(i=1;i<=n;i++){ for(j=1;j<i;j++){ if(d[j]!=0&&(i-j)%d[j]==0&&i<=j+d[j]*x[j]){ f[i]+=f[j]; f[i]%=mod; } } }ans=0; for(i=1;i<=n;i++) ans+=f[i],ans%=mod; cout<<ans; }else{ update(1,1); update(2,-1); for(i=1;i<=n;i++){ j=get(i); update(i+1,j); update(i+x[i]+1,-j); } for(i=1;i<=n;i++){ ans+=get(i); ans%=mod; }cout<<ans; } return 0; }

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp: In function 'int main()':
Main.cpp:31:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |   freopen(taskname".inp","r",stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:32:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |   freopen(taskname".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...