# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
534704 | kappa | Kutije (COCI21_kutije) | C++14 | 1066 ms | 17252 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define pii pair<long long, long long>
#define pb push_back
#define st first
#define nd second
using namespace std;
long long n, m, k, d[1005], s[1005][1005], ol[1005][1005], vis[1005];
set<int> st[1005];
unordered_map<int, vector<int> > mp;
int main(){
scanf("%lld %lld %lld", &n, &m, &k);
for (int i = 1; i <= m; ++i)
{
for (int j = 1; j <= n; ++j)
{
long long temp;
scanf("%lld", &temp);
//s[i][temp] = j;
//st[temp].insert(j);
mp[temp].pb(j);
}
}
/*queue<pii> q;
/*for (int i = 1; i <= n; ++i)
{
q.push({i, i});
}
//q.push({1, 1});
while(!q.empty()){
pii curr = q.front();
q.pop();
if(ol[curr.nd][curr.st]){
continue;
}
ol[curr.nd][curr.st] = 1;
for (int i = 1; i <= m; ++i)
{
q.push({s[i][curr.st], curr.nd});
}
}*/
/*for (int i = 1; i <= n; ++i)
{
cout << i << " ";
for (int j = 1; j <= n; ++j)
{
cout << ol[i][j];
}
cout << "\n";
}*/
while(k--){
long long l, r;
scanf("%lld %lld", &l, &r);
/*if(ol[l][r]){
printf("DA\n");
}else{
printf("NE\n");
}*/
if(ol[l][l] == 1){
if(ol[l][r] == 1){
cout << "DA\n";
}else{
cout << "NE\n";
}
continue;
}
queue<pii> q;
q.push({l, l});
while(!q.empty()){
pii curr = q.front();
q.pop();
if(ol[curr.nd][curr.st]){
continue;
}
ol[curr.nd][curr.st] = 1;
for (auto i : mp[curr.st])
{
//cout << curr.st << " " << i << "\n";
if(ol[curr.nd][i] == 0){
q.push({i, curr.nd});
}
}
}
if(ol[l][r] == 0){
cout << "NE\n";
}else{
cout << "DA\n";
}
memset(vis, 0, sizeof vis);
}
}
컴파일 시 표준 에러 (stderr) 메시지
# | 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... |