답안 #22258

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
22258 2017-04-30T03:16:29 Z AcornCkiGs14004Team(#953, gs14004, cki86201, dotorya) Unifying Values (KRIII5_UV) C++
0 / 7
6 ms 3224 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef long double llf;
typedef pair<int, int> pi;
const int mod = 1e9 + 7;

int n;
lint a[10005];
vector<int> v[10005];
vector<lint> dyn[10005];

lint dabs(lint x){ return max(x, -x); }

lint solve(int x){
	for(int i=0; i<=x; i++){
		v[i].clear();
		dyn[i].clear();
	}
	lint q = a[n] / x;
	for(int i=0; i<=n; i++){
		if(dabs(a[i]) % dabs(q) == 0){
			v[a[i] / q].push_back(i);
		}
	}
	for(int i=0; i<=x; i++){
		if(v[i].size() == 0) return 0;
		dyn[i].resize(v[i].size());
	}
	dyn[0][0] = 1;
	for(int i=1; i<=x; i++){
		int pt = 0;
		lint sum = 0;
		for(int j=0; j<v[i].size(); j++){
			while(pt < v[i-1].size() && v[i-1][pt] < v[i][j]){
				sum += dyn[i-1][pt];
				pt++;
			}
			sum %= mod;
			dyn[i][j] = sum;
		}
	}
	return dyn[x].back();
}

int main(){
	cin >> n;
	for(int i=1; i<=n; i++){
		lint x;
		cin >> x;
		a[i] = a[i-1] + x;
	}
	if(a[n] == 0){
		lint ans = 1;
		for(int i=1; i<n; i++){
			if(a[i] == 0) ans = ans * 2 % mod;
		}
		cout << (ans + mod - 1) % mod;
		return 0;
	}
	lint ret = 0;
	for(int i=2; i<=n; i++){
		if(a[n] % i == 0){
			ret += solve(i);
		}
	}
	cout << ret % mod;
}

Compilation message

UV.cpp: In function 'lint solve(int)':
UV.cpp:34:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int j=0; j<v[i].size(); j++){
                 ^
UV.cpp:35:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    while(pt < v[i-1].size() && v[i-1][pt] < v[i][j]){
             ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2564 KB Output is correct
2 Correct 0 ms 2564 KB Output is correct
3 Correct 0 ms 2564 KB Output is correct
4 Correct 3 ms 3224 KB Output is correct
5 Correct 6 ms 3224 KB Output is correct
6 Correct 0 ms 2564 KB Output is correct
7 Correct 3 ms 2828 KB Output is correct
8 Correct 3 ms 2828 KB Output is correct
9 Correct 3 ms 2828 KB Output is correct
10 Runtime error 0 ms 2696 KB Execution killed because of forbidden syscall writev (20)
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 2828 KB Execution killed because of forbidden syscall writev (20)
2 Halted 0 ms 0 KB -