제출 #1281534

#제출 시각아이디문제언어결과실행 시간메모리
1281534testaccountTrains (BOI24_trains)C++20
21 / 100
2095 ms1752 KiB
#include <bits/stdc++.h>
using namespace std;

#define     el "\n"
#define     FOR(i,a,b) for(int i = (a), _b = (b); i <= _b; i++)
#define     FORD(i,a,b) for(int i = (a), _b = (b); i >= _b; i--)
#define     pb push_back
#define     fi first
#define     se second
#define     all(x) x.begin(),x.end()
#define     lg(x) __lg(x)
#define     alla(a,n) a+1,a+n+1
#define     ll long long


template <class T> bool maxi(T &x, T y) { if(x < y) { x = y ; return true ;} return false;}
template <class T> bool mini(T &x, T y) { if(x > y) { x = y ; return true ;} return false;}

const int sm = 1e9 + 7;
const int N = 1e5 + 2;

int n, x[N], d[N];

void inp()
{
    cin >> n;
    FOR(i, 1, n) cin >> d[i] >> x[i];
}

/* Try your best
    No regrets */
void add(int &x, int y)
{
    x += y;
    if(x >= sm) x -= sm;
    if(x < 0) x += sm;
}
namespace subtask_1
{
    int dp[N];

    void slv()
    {
        dp[1] = 1;
        FOR(i, 1, n - 1) if(d[i]) {
            FOR(t, 1, x[i]) {
                int far = i + d[i] * t;
                if(far > n) break;
                add(dp[far], dp[i]);
            }
        }
        int ans = 0;
        FOR(i, 1, n) add(ans, dp[i]);
        cout << ans;
    }
}

/* Code slowly, think carefully */

main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    #define __Azul__ "trains"
    if(fopen(__Azul__".inp", "r")) {
        freopen(__Azul__".inp", "r", stdin);
        freopen(__Azul__".out", "w", stdout);
    }

    bool qs = 0;

    int T = 1;
    if(qs) cin >> T;
    while(T--) {
        inp();
        subtask_1::slv();
    }

    cerr << "\nTime" << 0.001 * clock() << "s "; return 0;


}





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

Main.cpp:60:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   60 | main()
      | ^~~~
Main.cpp: In function 'int main()':
Main.cpp:66:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   66 |         freopen(__Azul__".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:67:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   67 |         freopen(__Azul__".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...