Submission #758027

#TimeUsernameProblemLanguageResultExecution timeMemory
758027DexvaTowers (NOI22_towers)C++14
5 / 100
2072 ms115360 KiB
#include <bits/stdc++.h> using namespace std; #define lln long long void solve() { lln n; cin >> n; vector< pair<lln, lln> > points; map<lln, vector<lln> > xs; //for each map<lln, vector<lln> > ys; for (lln i=0;i<n;i++) { lln x, y; cin >> x >> y; if (xs.find(x) != xs.end()) xs[x].push_back(i); else { vector<lln> nx; nx.push_back(i); xs[x] = nx; } if (ys.find(y) != ys.end()) ys[y].push_back(i); else { vector<lln> ny; ny.push_back(i); ys[y] = ny; } points.push_back(make_pair(x,y)); } // for (const auto& x : xs) { // vector<lln> xentry = x.second; // cout << x.first << " | "; // for (lln i=0;i<xentry.size();i++) cout << xentry[i] << " "; // cout << '\n'; // } // for (const auto& x : ys) { // vector<lln> xentry = x.second; // cout << x.first << " | "; // for (lln i=0;i<xentry.size();i++) cout << xentry[i] << " "; // cout << '\n'; // } string ans = ""; for (lln i=0;i<n;i++) { lln x = get<0>(points[i]), y = get<1>(points[i]); //check the points on the same row (i.e., same y-value) as i, is i the one with least x or most x? vector<lln> row = ys[y]; lln minx = i, maxx = i; for (const auto& p : row) { if (get<0>(points[p])<get<0>(points[minx])) minx = p; if (get<0>(points[p])>get<0>(points[maxx])) maxx = p; } //check the points on the same column (i.e., same x-value) as i, is i the one with least y or most y? vector<lln> col = xs[x]; lln miny = i, maxy = i; for (const auto& p : col) { if (get<1>(points[p])<get<1>(points[miny])) miny = p; if (get<1>(points[p])>get<1>(points[maxy])) maxy = p; } // cout << "Point " << i << " " << minx << " " << maxx << " " << miny << " " << maxy << '\n'; if (minx==i && miny==i) ans += "1"; else if (minx==i && maxy==i) ans += "1"; else if (maxx==i && miny==i) ans += "1"; else if (maxx==i && maxy==i) ans += "1"; else ans += "0"; // (!(minx==i || maxx==i) && !(miny==i || maxy==i)) ans += "0"; // else ans += "1"; } cout << ans << '\n'; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int t = 1; while (t--) solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...