Submission #660310

#TimeUsernameProblemLanguageResultExecution timeMemory
660310600MihneaBuilding Skyscrapers (CEOI19_skyscrapers)C++17
8 / 100
121 ms6560 KiB
bool home = 0; #include <bits/stdc++.h> using namespace std; struct T { int x; int y; }; bool operator < (T a, T b) { if (a.x != b.x) { return a.x < b.x; } return a.y < b.y; } const int N = 150000 + 7; int n; int task; T points[N]; bool vis[N]; map<T, int> w; int main() { if (home == 0) { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); } else { freopen ("input.txt", "r", stdin); } cin >> n >> task; assert(task == 1 || task == 2); for (int i = 1; i <= n; i++) { cin >> points[i].x >> points[i].y; w[points[i]] = i; } vector<int> ord; int start = 1; queue<int> q; q.push(start); vis[start] = 1; while (!q.empty()) { int a = q.front(); ord.push_back(a); q.pop(); for (int dx = -1; dx <= +1; dx++) { for (int dy = -1; dy <= +1; dy++) { T nw = {points[a].x + dx, points[a].y + dy}; if (w.count(nw)) { int j = w[nw]; if (vis[j] == 0) { vis[j] = 1; q.push(j); } } } } } if ((int) ord.size() != n) { cout << "NO\n"; return 0; } cout << "YES\n"; for (auto &v : ord) { cout << v << "\n"; } return 0; }

Compilation message (stderr)

skyscrapers.cpp: In function 'int main()':
skyscrapers.cpp:36:13: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 |     freopen ("input.txt", "r", stdin);
      |     ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#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...