이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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();
}
컴파일 시 표준 에러 (stderr) 메시지
Main.cpp:20:21: warning: overflow in conversion from 'long long int' to 'int' changes value from '1152921504606846975' to '-1' [-Woverflow]
20 | int inf = LLONG_MAX >> 3;
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |