답안 #994754

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
994754 2024-06-08T04:55:27 Z salmon Trains (BOI24_trains) C++14
0 / 100
50 ms 38908 KB
#include <bits/stdc++.h>
using namespace std;

vector<int> v;
map<int,long long int> mep[100100];
vector<int> rebove[100100];
int N;
int d,x;
vector<pair<int,int>> iv;
long long int num[100100];
long long int mod = 1'000'000'007;

int main(){
	
	scanf(" %d",&N);
	
	for(int i = 0; i < N; i++){
		scanf(" %d",&d);
		scanf(" %d",&x);
		iv.push_back({d,x});
		num[i] = 0;
		rebove[(long long int)min((long long int)N,i + (long long int)d * x)].push_back(i);
	}
	
	/*for(int i = 0; i < N; i++){
		if(iv[i].first != 0){
			d = iv[i].first;
			x = iv[i].second;
			for(int j = 1; j <= x && j * d + i < N; j++){
				sat[j * d + i].insert(d);
				if(iv[j * d + i].first == d){
					x = max(x,j + iv[j * d + i].second);
					iv[j * d + i] = {0,0};
				}
			}
			
		}
	}*/
	
	num[0] = 1;
	long long int sum = 0;
	
	for(int i = 0; i < N; i++){
		num[i] %= mod;
		
		mep[min(N,i + iv[i].first)][iv[i].first] += num[i];
		
		for(int j : rebove[i]){
			mep[i][iv[j].first] = (mep[i][iv[j].first] - num[j]) % mod;
			num[min(N,j + iv[j].first)] -= num[j];
		}
		
		for(pair<int,long long int> j : mep[i]){
			if(j.second == 0) continue;
			mep[min(N,i + j.first)][j.first] += j.second;
			num[min(N,i + j.first)] += j.second;
		}

		sum = (sum + num[i]) % mod;
		//printf("%lld\n",num[i]);
	}
	
	printf("%lld",(sum + mod) % mod);
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:15:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |  scanf(" %d",&N);
      |  ~~~~~^~~~~~~~~~
Main.cpp:18:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |   scanf(" %d",&d);
      |   ~~~~~^~~~~~~~~~
Main.cpp:19:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |   scanf(" %d",&x);
      |   ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 8028 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 8028 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 8024 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 50 ms 38908 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 8028 KB Output isn't correct
2 Halted 0 ms 0 KB -