QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#136501#4192. Index CaseRetiredButNotTired#WA 2ms4816kbC++171.7kb2023-08-08 21:48:472023-08-08 21:48:51

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-08-08 21:48:51]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:4816kb
  • [2023-08-08 21:48:47]
  • 提交

answer

// Hey there.. I love you <3
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

mt19937 rnd(time(nullptr));

const int N = 2e2 + 5, M = 11, mod = 1e9 + 7;
const double pi = acos(-1), eps = 1e-10;

int n, m, s[N], f[M][M][M], vis[N * M * M];

vector<int> adj[N * M * M];

bool dfs(int u, int c) {
    
    if (c > n) return false;
    if (vis[u]) return true;
    vis[u] = 1;
    
    for (auto v: adj[u])
        if (dfs(v, c + 1))
            return true;
    
    return false;
}

void work() {
    
    cin >> n >> m;
    for (int i = 0; i < m; ++i)
        for (int j = 0; j < m; ++j)
            for (int k = 0; k < m; ++k)
                cin >> f[i][j][k], --f[i][j][k];
    
    for (int i = 0; i < n; ++i)
        cin >> s[i], --s[i];
    
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < m; ++j)
            for (int k = 0; k < m; ++k)
                for (int l = 0; l < m; ++l) {
                    if (f[j][k][l] == s[i])
                        adj[i * 100 + j * 10 + k].push_back((i + 1) % n * 100 + k * 10 + l);
                }
    
    for (int j = 0; j < m; ++j)
        for (int k = 0; k < m; ++k) {
            int u = 10 * j + k;
            memset(vis, 0, sizeof vis);
            if (dfs(u, 0))
                return void(cout << "yes" << endl);
        }
    
    cout << "no" << endl;
    
    
}


void init() {
    cin.tie(nullptr);
    istream::sync_with_stdio(false);
//    freopen("in.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);


}

int main() {
    init();
    
    int testCases = 1;
//    cin >> testCases;
    while (testCases--) work();
    
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 4340kb

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: 1ms
memory: 4224kb

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: -100
Wrong Answer
time: 2ms
memory: 4816kb

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:

yes

result:

wrong answer expected NO, found YES