QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#345256#3414. Diagrams & TableauxPetroTarnavskyi#AC ✓1933ms4104kbC++201.3kb2024-03-06 18:11:222024-03-06 18:11:22

Judging History

你现在查看的是最新测评结果

  • [2024-03-06 18:11:22]
  • 评测
  • 测评结果:AC
  • 用时:1933ms
  • 内存:4104kb
  • [2024-03-06 18:11:22]
  • 提交

answer

#include <bits/stdc++.h> 

using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (a) - 1; i >= (b); i--)
#define SZ(a) int(a.size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair
#define F first
#define S second

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef double db;

VI row;
vector<VI> rows[8];

void gen()
{
	rows[SZ(row)].PB(row);
	if (SZ(row) == 7)
		return;
	FOR(val, row.empty() ? 1 : row.back(), 8)
	{
		row.PB(val);
		gen();
		row.pop_back();
	}
}

int k;

void solve()
{
	VI l(k);
	for (int& li : l)
		cin >> li;
	int n;
	cin >> n;
	vector<LL> dp(SZ(rows[l[0]]));
	FOR(j, 0, SZ(rows[l[0]]))
		if (rows[l[0]][j].back() <= n)
			dp[j] = 1;
	FOR(i, 0, k - 1)
	{
		vector<LL> ndp(SZ(rows[l[i + 1]]));
		FOR(j1, 0, SZ(rows[l[i]]))
		{
			FOR(j2, 0, SZ(rows[l[i + 1]]))
			{
				bool ok = rows[l[i + 1]][j2].back() <= n;
				FOR(p, 0, l[i + 1])
				{
					ok &= rows[l[i]][j1][p] < rows[l[i + 1]][j2][p];
				}
				if (ok)
					ndp[j2] += dp[j1];
			}
		}
		dp = ndp;
	}
	cout << accumulate(ALL(dp), 0LL) << "\n";	
}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	gen();
	while (cin >> k)
		solve();
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 4104kb

input:

1 1
1
1 1
2
2 2 1
4
4 3 2 1 1
4

output:

1
2
20
20

result:

ok 4 lines

Test #2:

score: 0
Accepted
time: 1933ms
memory: 3848kb

input:

4 7 7 7 2
5
5 6 6 4 2 2
7
6 6 6 4 3 2 1
7
7 7 7 7 7 4 2 2
7
7 7 7 7 7 5 3 2
7
6 6 6 5 3 2 1
7
7 7 7 7 7 5 2 2
7
4 7 6 4 1
5
6 6 6 6 6 4 2
7
5 6 6 6 3 1
7
7 7 7 7 7 7 3 2
7
4 7 7 6 1
5
6 6 6 6 4 2 1
7
6 6 6 6 5 2 1
7
4 7 7 6 2
5
6 6 6 6 6 6 6
7
4 7 6 4 2
5
5 6 6 6 5 3
7
7 7 7 7 6 3 2 2
7
7 7 7 7 5 4 ...

output:

6930
2656192
2838528
194040
124740
3492720
138600
31185
336798
3430350
19404
15840
2587200
1892352
15400
924
26730
1778700
465696
519750
21560
2097152
4752
462
56
2276736
12936
1155
224
66528
473088
3201660
13860
6468
41580
4125
20
623700
8
242550
155232
762300
26400
5292540
727650
360
2475
23100
10...

result:

ok 108 lines