Submission #851825

# Submission time Handle Problem Language Result Execution time Memory
851825 2023-09-20T16:36:39 Z vjudge1 Kutije (COCI21_kutije) C++17
20 / 70
1000 ms 1392 KB
#include <bits/stdc++.h>
using namespace std;

#pragma GCC optimize("Ofast,O3,unroll-loops")
#define int long long
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define vpi vector<pii>
#define vvpi vector<vpi>
#define vb vector<bool>
#define vvb vector<vb>
#define endl "\n"
#define sp << " " <<
#define F(i, s, n) for(int i = s; i < n; i++)
#define pb push_back
#define fi first
#define se second

int inf = LLONG_MAX >> 3;

vvi adj(1001);
vb visited(1001);
int x, y;
bool ans = false;
void dfs(int node) {
    if(visited[node]) return;
    visited[node] = true;
    if(node == y) {
        ans = true;
        return;
    }
    for(int nei: adj[node]) dfs(nei);
}
void solve() {
    int n, m, q;
    cin >> n >> m >> q;
    F(i, 0, m) {
        F(j, 0, n) {
            int x;
            cin >> x;
            x--;
            adj[x].pb(j);
        }
    }
    F(i, 0, q) {
        visited.assign(n, false);
        cin >> x >> y;
        x--, y--;
        ans = false;
        dfs(x);
        if(ans) cout << "DA" << endl;
        else cout << "NE" << endl;
    }
}
void setIO() {
    ios::sync_with_stdio(0); cin.tie(0);
    #ifdef Local
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
}
signed main() {
    setIO();
    solve();
}
# Verdict Execution time Memory Grader output
1 Execution timed out 1064 ms 1392 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 2 ms 604 KB Output is correct
4 Correct 2 ms 604 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 2 ms 600 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
9 Correct 1 ms 600 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 2 ms 604 KB Output is correct
4 Correct 2 ms 604 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 2 ms 600 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
9 Correct 1 ms 600 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 1 ms 604 KB Output is correct
13 Correct 2 ms 604 KB Output is correct
14 Correct 2 ms 604 KB Output is correct
15 Correct 2 ms 344 KB Output is correct
16 Correct 1 ms 604 KB Output is correct
17 Correct 3 ms 604 KB Output is correct
18 Correct 1 ms 604 KB Output is correct
19 Correct 1 ms 604 KB Output is correct
20 Correct 2 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1064 ms 1392 KB Time limit exceeded
2 Halted 0 ms 0 KB -