Submission #1028723

#TimeUsernameProblemLanguageResultExecution timeMemory
1028723DeltaStruct산악 구조대 (JOI13_mountain)C++17
0 / 100
4 ms976 KiB
#include <bits/stdc++.h> using namespace std; int Measure(int RM,int CM); void Pinpoint(int RP,int CP); /* vector<vector<int>> high; vector<pair<int,int>> ans; int Measure(int RM,int CM){ return high[RM-1][CM-1]; } void Pinpoint(int RP,int CP){ ans.emplace_back(RP,CP); } void Rescue(int R,int C,int MR,int MC,int X); int main(){ int q; cin >> q; while(q--){ int R,C,MR,MC,X; cin >> R >> C >> MR >> MC >> X; high.resize(R); for (auto& a:high){ a.resize(C); for (int& b:a) cin >> b; } Rescue(R,C,MR,MC,X); } for (auto [a,b]:ans) cout << a << ' ' << b << endl; } //*/ void Rescue(int R,int C,int MR,int MC,int X){ --MR; int x = 0,y = MC-1; while(x!=MR+1&&y!=-1){ int r = Measure(x+1,y+1); if (r==X){ Pinpoint(x+1,y+1); return; } if (r<X) ++x; else --y; } x = 0,y = MC-1; while(x!=MR+1&&y!=C){ int r = Measure(x+1,y+1); if (r==X){ Pinpoint(x+1,y+1); return; } if (r<X) ++x; else ++y; } x = R-1,y = MC-1; while(x!=MR+1&&y!=-1){ int r = Measure(x+1,y+1); if (r==X){ Pinpoint(x+1,y+1); return; } if (r<X) --x; else --y; } x = R-1,y = MC-1; while(x!=MR-1&&y!=C){ int r = Measure(x+1,y+1); if (r==X){ Pinpoint(x+1,y+1); return; } if (r<X) --x; else ++y; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...