제출 #1098059

#제출 시각아이디문제언어결과실행 시간메모리
1098059VinhLuuTrains (BOI24_trains)C++17
100 / 100
196 ms127088 KiB
#include <bits/stdc++.h> //#define int long long #define ll long long #define fi first #define se second #define all(vin) vin.begin(), vin.end() using namespace std; typedef pair<int,int> pii; typedef pair<pii,int> tp; const int N = 1e5 + 2; //const int oo = -1e16; const int mod = 1e9 + 7; int n, d[N], x[N], block, g[318][N], f[N]; void get(int &x,int y){ x = (x + y) % mod; } signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define task "v" if(fopen(task ".inp","r")){ freopen(task ".inp","r",stdin); freopen(task ".out","w",stdout); } cin >> n; block = sqrt(n); vector<int> vr; for(int i = 1; i <= n; i ++){ cin >> d[i] >> x[i]; if(d[i] <= block) vr.push_back(d[i]); } sort(all(vr)); vr.resize(unique(all(vr)) - vr.begin()); for(int i = 1; i <= n; i ++) f[i] = 1; for(int i = n; i >= 1; i --){ if(d[i] > block){ for(int j = 1; j <= x[i] && i + 1ll * j * d[i] <= n; j ++) get(f[i], f[i + 1ll * j * d[i]]); }else{ int val = 0; if(x[i] && i + 1ll * (x[i] + 1) * d[i] <= n) val = (mod - g[d[i]][i + 1ll * (x[i] + 1) * d[i]]) % mod; if(x[i]) get(f[i], (g[d[i]][i + d[i]] + val) % mod); } for(auto j : vr){ get(g[j][i], f[i] + (i + j <= n ? g[j][i + j] : 0)); } } cout << f[1]; }

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

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