Submission #1302417

#TimeUsernameProblemLanguageResultExecution timeMemory
1302417machianhTowers (NOI22_towers)C++20
0 / 100
1 ms468 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; mt19937_64 rng(time(0)); ll random(ll l, ll r) { return l + rng() % (r - l + 1); } const int MAXN = 5008; int n; struct giaolo { int x, y; } a[MAXN]; namespace subtask2 { const int TMP_MAXN = 23; int c[TMP_MAXN]; bool check() { return n <= 17; } bool check_state() { unordered_map<int, int> dx, dy; for(int i = 1; i <= n; i++) { if(c[i] == 1) { dx[a[i].x]++; dy[a[i].y]++; } else { bool dong = false, tay = false, nam = false, bac = false; for(int j = 1; j <= n; j++) { if(c[j] == 1) { if(a[j].x < a[i].x && a[i].y == a[j].y) { tay = true; } if(a[j].x > a[i].x && a[i].y == a[j].y) { dong = true; } if(a[j].y < a[i].y && a[i].x == a[j].x) { nam = true; } if(a[j].y > a[i].y && a[i].x == a[j].x) { bac = true; } } } if(!((dong && tay) || (nam && bac))) { return false; } } if(dx[a[i].x] > 2 || dy[a[i].y] > 2) { return false; } } } void Try(int i) { for(int j = 0; j <= 1; j++) { c[i] = j; if(i == n) { if(check_state()) { for(int i = 1; i <= n; i++) { cout << c[i]; } exit(0); } } else { Try(i + 1); } } } void main_solve() { Try(1); } } namespace subtask3 { bool check() { unordered_map<int, int> dx; for(int i = 1; i <= n; i++) { dx[a[i].x]++; if(dx[a[i].x] > 2) { return false; } } return true; } unordered_map<int, pair<int, int>> dy; bool ans[MAXN]; void main_solve() { for(int i = 1; i <= n; i++) { dy[a[i].x].first = max(dy[a[i].x].first, a[i].y); dy[a[i].x].second = min(dy[a[i].x].second, a[i].y); } for(int i = 1; i <= n; i++) { if(dy[a[i].x].first == a[i].y) { ans[i] = true; } if(dy[a[i].x].second == a[i].y) { ans[i] = true; } } for(int i = 1;i <= n; i++) { cout << ans[i]; } } } int32_t main() { if(fopen("SLAMP.inp", "r")) { freopen("SLAMP.inp", "r", stdin); freopen("SLAMP.out", "w", stdout); } cin.tie(0) -> ios_base::sync_with_stdio(0); cin >> n; for(int i = 1; i <= n ;i++) { cin >> a[i].x >> a[i].y; } if(subtask2::check()) { subtask2::main_solve(); } else { subtask3::main_solve(); } }

Compilation message (stderr)

Main.cpp: In function 'bool subtask2::check_state()':
Main.cpp:68:5: warning: control reaches end of non-void function [-Wreturn-type]
   68 |     }
      |     ^
Main.cpp: In function 'int32_t main()':
Main.cpp:133:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  133 |         freopen("SLAMP.inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:134:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  134 |         freopen("SLAMP.out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
#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...