제출 #1247917

#제출 시각아이디문제언어결과실행 시간메모리
1247917hainam2k9Trains (BOI24_trains)C++20
100 / 100
77 ms5956 KiB
#include <bits/stdc++.h>
#define tt cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(0)
#define fo freopen((NAME+".INP").c_str(), "r", stdin), freopen((NAME+".OUT").c_str(), "w", stdout)
#define ll long long
#define ull unsigned long long
#define i128 __int128
#define db long double
#define sz(a) ((int)(a).size())
#define pb emplace_back
#define pf emplace_front
#define pob pop_back
#define pof pop_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define ins emplace
#define mp make_pair
using namespace std;
const int MOD = 1e9+7, MAXN = 1e5+5, SQRT = 320;
const string NAME = "";
int n,dp[MAXN],sum[350][350],rs=0;
pair<int,int> p[MAXN];
vector<int> upd[MAXN];
inline void add(int& a, int b){
    a+=b;
    if(a>=MOD) a-=MOD;
}
inline void sub(int& a, int b){
    a-=b;
    if(a<0) a+=MOD;
}
int main()
{
    tt;
    if(fopen((NAME + ".INP").c_str(), "r")) fo;
    cin >> n;
    for(int i = 1; i<=n; ++i){
        cin >> p[i].fi >> p[i].se;
        if(p[i].fi!=0) p[i].se=min(p[i].se,(n-i)/p[i].fi);
        p[i].se=i+p[i].se*p[i].fi;
    }
    dp[1]=1;
    for(int i = 1; i<=n; ++i){
        for(int j = 1; j<SQRT; ++j)
            add(dp[i],sum[j][i%j]);
        add(rs,dp[i]);
        if(p[i].fi!=0){
            if(p[i].fi>=SQRT){
                for(int j = i+p[i].fi; j<=p[i].se; j+=p[i].fi)
                    add(dp[j],dp[i]);
            }else add(sum[p[i].fi][i%p[i].fi],dp[i]), upd[p[i].se].pb(i);
        }
        for(int& j : upd[i])
            sub(sum[p[j].fi][j%p[j].fi],dp[j]);
    }
    cout << rs;
}

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

Main.cpp: In function 'int main()':
Main.cpp:3:19: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    3 | #define fo freopen((NAME+".INP").c_str(), "r", stdin), freopen((NAME+".OUT").c_str(), "w", stdout)
      |            ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:36:45: note: in expansion of macro 'fo'
   36 |     if(fopen((NAME + ".INP").c_str(), "r")) fo;
      |                                             ^~
Main.cpp:3:63: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    3 | #define fo freopen((NAME+".INP").c_str(), "r", stdin), freopen((NAME+".OUT").c_str(), "w", stdout)
      |                                                        ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:36:45: note: in expansion of macro 'fo'
   36 |     if(fopen((NAME + ".INP").c_str(), "r")) fo;
      |                                             ^~
#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...