F.A.Qs Home ProblemSet Status Ranklist Contest LoginRegister
Notice:1:注册本OJ方式请见https://www.lydsy.com/JudgeOnline/wttl/thread.php?tid=5671 2:请不要在讨论区中发空白主题帖。
大视野在线测评-欢迎您
[ New Thread ]
Problem 1019 >> 求大佬帮忙看看,本地720*30组数据都拍过了
liyuankai @ 2018-11-02 13:17:25
[ Quote ] [ Edit ] [ Delete ] 1#
#include <iostream>
#include <algorithm>
using namespace std;
char s[7][2];
int a[3][1010],tail[3] = {0},pr[7][2],n;
int cnt = 0,last = 99999;
inline bool move(int from,int to) {
if (!tail[from])
return 0;
if (a[from][tail[from]] == last)
return 0;
if (a[from][tail[from]] > a[to][tail[to]])
return 0;
last = a[from][tail[from]];
a[to][++tail[to]] = a[from][tail[from]];
tail[from]--;
}
int p[7];
inline int work(int x) {
cnt = 0;
n = x;
a[0][0] = a[1][0] = a[2][0] = n+1;
last = 0;
for (int i = 1;i <= 6; i++) {
pr[i][0] = s[p[i]][0]-'A';
pr[i][1] = s[p[i]][1]-'A';
}
tail[0] = tail[1] = tail[2] = 0;
for (int i = n;i >= 1; i--)
a[0][++tail[0]] = i;
while (tail[1] < n && tail[2] < n) {
for (int i = 1;i <= 6; i++)
if (move(pr[i][0],pr[i][1]))
break;
cnt++;
}
return cnt;
}
int m;
int main() {
cin >> m;
long long ans = 1;
for (int i = 1;i <= 6; i++)
cin >> s[i],p[i] = i;
if (work(3) == 7) {
for (int i = 2;i <= m; i++)
ans = ans*2+1;
}
else if (work(3) == 17) {
for (int i = 2;i <= m; i++)
ans = ans*3+2;
}
else
for (int i = 2;i <= m; i++)
ans = ans*3;
cout << ans << endl;
return 0;
}
/*
1
AB BA BC CB AC CA
30
BC CB AC AB CA BA
*/
liyuankai @ 2018-11-02 13:17:43
[ Quote ] [ Edit ] [ Delete ] 2#
疯狂WA
[Top] [Previous Page] [Next Page]

HOME Back