Submission #564523

#TimeUsernameProblemLanguageResultExecution timeMemory
5645231zaid1Building Skyscrapers (CEOI19_skyscrapers)C++17
0 / 100
795 ms1048576 KiB
#include <bits/stdc++.h> using namespace std; #define endl '\n' #define int long long typedef long long ll; const int M = 2e7 + 5, MOD = 1e9+7; int vis[M], cnt; vector<int> node[M]; struct point {int x, y, i;}; vector<int> ans; void bfs(int s) { queue<int> q; q.push(s); while (!q.empty()) { int t = q.front(); q.pop(); ans.push_back(t); for (int i:node[t]) { if (!vis[i]) q.push(i); } } } signed main() { ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); srand(time(0)); int n, t; cin >> n >> t; vector<point> v(n); for (auto&i:v) cin >> i.x >> i.y; int ind = 1; for (auto&i:v) i.i = ind++; vector<point> p; sort(v.begin(), v.end(), [](point a, point b){if (a.y == b.y) return a.x < b.x; return a.y < b.y;}); for (int i = 0; i < n; i++) { while (i < n && (!i || v[i].y == v[i-1].y)) { p.push_back(v[i++]); } for (int j = 1; j < p.size(); j++) { if (p[j-1].x+1 == p[j].x) { node[p[j].i].push_back(p[j-1].i); node[p[j-1].i].push_back(p[j].i); } } p.clear(); p.push_back(v[i]); } p.clear(); sort(v.begin(), v.end(), [](point a, point b){if (a.x == b.x) return a.y < b.y; return a.x < b.x;}); for (int i = 0; i < n; i++) { while (i < n && (!i || v[i].x == v[i-1].x)) { p.push_back(v[i++]); } for (int j = 1; j < p.size(); j++) { if (p[j-1].y+1 == p[j].y) { node[p[j].i].push_back(p[j-1].i); node[p[j-1].i].push_back(p[j].i); } } p.clear(); p.push_back(v[i]); } p.clear(); sort(v.begin(), v.end(), [](point a, point b){if ((a.x+a.y) == (b.x+b.y)) return a.x < b.x; return a.x+a.y < b.x+b.y;}); for (int i = 0; i < n; i++) { while (i < n && (!i || (v[i].x+v[i].y) == (v[i-1].x+v[i-1].y))) { p.push_back(v[i++]); } for (int j = 1; j < p.size(); j++) { if (p[j-1].x+1 == p[j].x) { node[p[j].i].push_back(p[j-1].i); node[p[j-1].i].push_back(p[j].i); } } p.clear(); p.push_back(v[i]); } p.clear(); sort(v.begin(), v.end(), [](point a, point b){if ((a.x-a.y) == (b.x-b.y)) return a.x < b.x; return a.x-a.y < b.x-b.y;}); for (int i = 0; i < n; i++) { while (i < n && (!i || (v[i].x-v[i].y) == (v[i-1].x-v[i-1].y))) { p.push_back(v[i++]); } for (int j = 1; j < p.size(); j++) { if (p[j-1].x+1 == p[j].x) { node[p[j].i].push_back(p[j-1].i); node[p[j-1].i].push_back(p[j].i); } } p.clear(); p.push_back(v[i]); } bfs(n); if (cnt == n) { cout << "YES" << endl; for (int i:ans) cout << i << endl; } else cout << "NO" << endl; return 0; } /* 3 2 0 0 0 1 0 2 */

Compilation message (stderr)

skyscrapers.cpp: In function 'int main()':
skyscrapers.cpp:44:27: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<point>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |         for (int j = 1; j < p.size(); j++) {
      |                         ~~^~~~~~~~~~
skyscrapers.cpp:62:27: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<point>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   62 |         for (int j = 1; j < p.size(); j++) {
      |                         ~~^~~~~~~~~~
skyscrapers.cpp:80:27: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<point>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   80 |         for (int j = 1; j < p.size(); j++) {
      |                         ~~^~~~~~~~~~
skyscrapers.cpp:98:27: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<point>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   98 |         for (int j = 1; j < p.size(); j++) {
      |                         ~~^~~~~~~~~~
#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...