답안 #98469

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
98469 2019-02-23T18:26:35 Z luciocf Zoltan (COCI16_zoltan) C++14
14 / 140
793 ms 512 KB
#include <bits/stdc++.h>

using namespace std;

const int maxn = 22;
const int mod = 1e9+7;

typedef long long ll;

int num[maxn], dp[maxn];

ll qtd[maxn];

int main(void)
{
	int n;
	ll q = 0LL;
	cin >> n;

	for (int i = 0; i < n; i++)
		cin >> num[i];

	int ans = 0;

	for (int mask = 0; mask < (1<<n); mask++)
	{
		int aux = 0;

		deque<int> dq;

		if (!(mask&1)) continue;

		for (int i = 0; i < n; i++)
		{
			if (mask&(1<<i)) dq.push_front(num[i]);
			else dq.push_back(num[i]);
		}

		vector<int> v;

		while (dq.size() > 0)
		{
			v.push_back(dq.front());
			dq.pop_front();
		}

		for (int i = 0; i < v.size(); i++)
		{
			dp[i] = qtd[i] = 1;
			for (int j = 0; j < i; j++)
				if (v[j] < v[i]) 
					dp[i] = max(dp[i], dp[j]+1);
		}

		for (int i = 0; i < v.size(); i++) aux = max(aux, dp[i]);

		if (aux < ans) continue;
		
		if (aux > ans) q = 0LL;
		ans = aux;

		for (int i = 0; i < v.size(); i++)
		{
			if (dp[i] < ans) continue;

			q = (q+qtd[i])%mod;
			for (int j = 0; j < i; j++)
				if (v[j] < v[i] && dp[j]+1 == dp[i])
					qtd[i] = (qtd[i]+qtd[j])%mod, q = (q+qtd[j])%mod;
		}
	}

	cout << ans << " " << q << "\n";
}

Compilation message

zoltan.cpp: In function 'int main()':
zoltan.cpp:47:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int i = 0; i < v.size(); i++)
                   ~~^~~~~~~~~~
zoltan.cpp:55:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int i = 0; i < v.size(); i++) aux = max(aux, dp[i]);
                   ~~^~~~~~~~~~
zoltan.cpp:62:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int i = 0; i < v.size(); i++)
                   ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 638 ms 476 KB Output isn't correct
2 Incorrect 658 ms 360 KB Output isn't correct
3 Incorrect 793 ms 376 KB Output isn't correct
4 Correct 2 ms 256 KB Output is correct
5 Incorrect 562 ms 392 KB Output isn't correct
6 Correct 671 ms 376 KB Output is correct
7 Runtime error 3 ms 384 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Runtime error 3 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Runtime error 3 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Runtime error 3 ms 384 KB Execution killed with signal 11 (could be triggered by violating memory limits)
11 Runtime error 3 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
12 Runtime error 3 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
13 Runtime error 3 ms 384 KB Execution killed with signal 11 (could be triggered by violating memory limits)
14 Runtime error 2 ms 384 KB Execution killed with signal 11 (could be triggered by violating memory limits)
15 Runtime error 3 ms 384 KB Execution killed with signal 11 (could be triggered by violating memory limits)
16 Runtime error 3 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
17 Runtime error 3 ms 384 KB Execution killed with signal 11 (could be triggered by violating memory limits)
18 Runtime error 2 ms 384 KB Execution killed with signal 11 (could be triggered by violating memory limits)
19 Runtime error 2 ms 384 KB Execution killed with signal 11 (could be triggered by violating memory limits)
20 Runtime error 2 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)