QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#419007 | #4192. Index Case | zezoo050# | WA | 1ms | 4008kb | C++20 | 1.5kb | 2024-05-23 16:58:13 | 2024-05-23 16:58:14 |
Judging History
answer
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e2 + 5, M = 15;
int n, m;
int f[M][M][M], s[N];
vector<tuple<int,int,int>>inv[M];
int lst, frst, id;
int dp[N][M][M], vis[N][M][M];
int solve(int i, int prv, int force)
{
if(i == n - 1)
{
if(force != lst)
return 0;
for(auto& [a,b,c] : inv[s[i]])
{
if(a != prv || b != force)
continue;
if(c == frst)
return 1;
}
return 0;
}
int& ret = dp[i][prv][force];
if(vis[i][prv][force] == id)
return ret;
ret = 0, vis[i][prv][force] = id;
for(auto& [a,b,c] : inv[s[i]])
{
if(a != prv || b != force)
continue;
ret = max(ret, solve(i + 1, b, c));
}
return ret;
}
void tc()
{
cin >> n >> m;
for(int a = 1; a <= m; a++)
for(int b = 1; b <= m; b++)
for(int c = 1; c <= m; c++)
cin >> f[a][b][c], inv[f[a][b][c]].emplace_back(a, b, c);
for(int i= 0; i < n; i++)
cin >> s[i];
id++;
for(auto& [a, b, c] : inv[s[0]])
{
lst = a, frst = b;
if(solve(1, b, c))
return cout << "yes", void();
}
cout << "no";
}
signed main() {
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int t = 1;
// cin >> t;
while (t--) {
tc();
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3704kb
input:
4 2 1 2 1 2 2 1 2 1 1 2 1 2
output:
yes
result:
ok answer is YES
Test #2:
score: 0
Accepted
time: 1ms
memory: 3708kb
input:
6 2 1 2 1 2 2 1 2 1 1 2 1 2 1 2
output:
no
result:
ok answer is NO
Test #3:
score: 0
Accepted
time: 0ms
memory: 3636kb
input:
10 2 1 2 1 1 2 2 2 2 1 2 2 2 1 2 1 2 1 2
output:
yes
result:
ok answer is YES
Test #4:
score: 0
Accepted
time: 1ms
memory: 3748kb
input:
200 10 1 7 8 5 5 3 7 5 7 4 1 10 10 4 1 2 7 7 9 4 8 7 2 7 7 5 8 6 2 4 4 10 10 10 9 8 6 5 5 8 8 1 1 8 9 5 9 4 6 9 1 6 4 1 1 10 5 2 4 4 3 10 6 9 3 2 4 2 10 10 10 6 8 4 10 9 8 7 2 9 3 7 4 8 6 3 9 9 1 3 10 2 6 10 1 1 3 3 2 1 5 9 9 10 7 8 5 5 10 1 5 8 7 2 9 8 7 1 8 6 7 8 7 2 10 1 1 1 2 7 7 9 9 9 7 5 4 3 4...
output:
no
result:
ok answer is NO
Test #5:
score: -100
Wrong Answer
time: 0ms
memory: 4008kb
input:
200 10 10 8 1 1 8 3 5 6 5 2 8 7 9 10 6 5 5 2 7 6 8 2 1 7 5 2 10 1 2 9 9 3 4 2 9 8 1 10 3 5 2 8 9 5 3 4 2 1 10 2 3 6 6 8 3 8 4 1 4 1 6 9 4 10 1 7 8 3 4 2 10 10 1 2 10 6 10 8 5 6 5 5 10 2 4 5 5 9 10 6 6 10 9 6 8 5 5 10 3 9 1 5 5 2 6 6 8 8 2 4 4 6 1 7 10 3 4 6 10 4 10 7 9 2 10 6 2 10 7 4 6 6 1 7 3 1 9 ...
output:
no
result:
wrong answer expected YES, found NO