답안 #27009

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
27009 2017-07-08T11:20:19 Z noobprogrammer Brunhilda’s Birthday (BOI13_brunhilda) C++14
0 / 100
0 ms 1844 KB
#include <bits/stdc++.h>
using namespace std ;

int n , m , pr[100010] , mx[10000010] , cnt[10000010] , ptr , dp[10000010] , nc = 1 ;
int fr[10000010] , bk[10000010] , vv[10000010] , nxt[10000010] ;
const int N = 1e7 ; 

void upd(int x,int y){
	if(fr[x] == 0) {
		bk[x] = fr[x] = nc ;
		vv[nc] = y ;
		nc++ ;
	}
	else {
		nxt[bk[x]] = nc ;
		vv[nc] = y ;
		bk[x] = nc ;
		nc++;
	}
}

int main(){
	// freopen("in.txt" , "r" , stdin) ;
	// freopen("out.txt" , "w" , stdout) ;
	scanf("%d%d" , &n,&m ) ;
	int j ; 
	for(int i=0;i<n;i++) {
		scanf("%d" , pr+i) ;
		for( j=0 ; j <= 1e7 ; j+=pr[i]) mx[j] = max(mx[j] , pr[i]) ;
	}
	upd(mx[0]-1 , 1) ;
	cnt[1]++ ;
	int val = 1 , v ;
	for(int i=1;i<=N;i++){
		while(!cnt[val] && val <= 1e7 )	val++ ;
		dp[i] = val ;
		v = fr[i] ;
		while(v != bk[i]){
			cnt[vv[v]]-- ;
			v = nxt[v] ;
		}
		cnt[vv[v]]-- ;
		if(dp[i] == 1e7+1) continue ;
		if(!mx[i]) continue ;
		upd(i+mx[i]-1 , dp[i] + 1 ) ;
		cnt[dp[i]+1]++ ;
	}
	for(int i=0;i<m;i++){
		scanf("%d" , &val) ;
		if(dp[val] == 1e7+1) printf("oo\n") ;
		else printf("%d\n" , dp[val] ) ;
	}
}

Compilation message

brunhilda.cpp: In function 'int main()':
brunhilda.cpp:25:25: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d" , &n,&m ) ;
                         ^
brunhilda.cpp:28:22: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d" , pr+i) ;
                      ^
brunhilda.cpp:49:22: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d" , &val) ;
                      ^
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
11 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
12 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
13 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
14 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
15 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
16 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
17 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
18 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
11 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
12 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
13 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
14 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
15 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
16 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
17 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
18 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
11 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
12 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
13 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
14 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
15 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
16 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
17 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
18 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
19 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
20 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
21 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
22 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
23 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
24 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
25 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
26 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
27 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
28 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
29 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
30 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
31 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
32 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
33 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
34 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
35 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
36 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
37 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
38 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
39 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
40 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
41 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
42 Runtime error 0 ms 1844 KB Execution killed with signal 11 (could be triggered by violating memory limits)