이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define MAXN 600007
vector<int> adj[MAXN];
bool vis[MAXN];
void dfs(int u) {
for(int v: adj[u]) {
if(!vis[v]) {
vis[v] = 1;
dfs(v);
}
}
}
main(){
int r, c, n; cin >> r >> c >> n;
//r and c are useless lmao
int N = 0;
map<int, set< pair<int, bool> >> importantPts; int a, b;
map<int, set<int>> trampolines;
for (int x = 0; x < n; x++){
cin >> a >> b;
importantPts[a].insert({b, 1}); //1 indicating green trampoline
importantPts[a+1].insert({b, 0});
trampolines[a].insert(b);
N++; N++;
}
int q; cin >> q;
pair<int, int> starts[q], ends[q];
for (int x = 0; x < q; x++){
cin >> starts[x].first >> starts[x].second >> ends[x].first >> ends[x].second;
importantPts[ends[x].first].insert({ends[x].second, 0});
N++;
}
map<pair<int, int>, int> coordToNode;
pair<int, int> hmm[N];
int cnt = 0;
for (auto y : importantPts){
for (auto z : y.second){
coordToNode[{y.first, z.first}] = cnt;
hmm[cnt] = {y.first, z.first};
cnt++;
}
}
for (auto y : importantPts){ //gen DAG
pair<int, int> lastCoords = {-1, -1};
for (auto z : y.second){
if (lastCoords.first != -1) adj[coordToNode[lastCoords]].push_back(coordToNode[{y.first, z.first}]);
if (z.second){
adj[coordToNode[{y.first, z.first}]].push_back(coordToNode[{y.first+1, z.first}]);
}
lastCoords = {y.first, z.first};
}
}
for (int x = 0; x < q; x++){
auto startTramp = importantPts[starts[x].first].lower_bound({starts[x].second, 0});
if (starts[x].first > ends[x].first || startTramp == importantPts[starts[x].first].end()){
cout << "No\n"; continue;
}
int startF = starts[x].first, startS = startTramp->first;
bool found = false;
while (startF != ends[x].first){
auto lb = trampolines[startF].lower_bound(startS);
if (lb != trampolines[startF].end()){
startF++;
startS = *lb;
}
else break;
}
if (startF == ends[x].first && startS <= ends[x].second) found = true;
if (found) cout << "Yes\n";
else cout << "No\n";
}
}
컴파일 시 표준 에러 (stderr) 메시지
trampoline.cpp:20:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
20 | main(){
| ^~~~
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |