제출 #1105933

#제출 시각아이디문제언어결과실행 시간메모리
1105933RiverFlowTowers (NOI22_towers)C++14
100 / 100
695 ms120356 KiB
#include <bits/stdc++.h> #define nl "\n" #define no "NO" #define yes "YES" #define fi first #define se second #define vec vector #define task "main" #define _mp make_pair #define ii pair<int, int> #define sz(x) (int)x.size() #define all(x) x.begin(), x.end() #define evoid(val) return void(std::cout << val) #define FOR(i, a, b) for(int i = (a); i <= (b); ++i) #define FOD(i, b, a) for(int i = (b); i >= (a); --i) #define unq(x) sort(all(x)); x.resize(unique(all(x)) - x.begin()) using namespace std; template<typename U, typename V> bool maxi(U &a, V b) { if (a < b) { a = b; return 1; } return 0; } template<typename U, typename V> bool mini(U &a, V b) { if (a > b) { a = b; return 1; } return 0; } const int mod = (int)1e9 + 7; void prepare(); void main_code(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); if (fopen(task".inp", "r")) { freopen(task".inp", "r", stdin); freopen(task".out", "w", stdout); } const bool MULTITEST = 0; prepare(); int num_test = 1; if (MULTITEST) cin >> num_test; while (num_test--) { main_code(); } } void prepare() {}; const int N = (int)1e6 + 9; struct point { int x, y; }; point a[N]; pair<int, int> b[N]; vector<int> row[N]; vec<int> col[N]; void _fill(int rw, int j) { int c = a[j].x; col[c].push_back(j); sort(all(col[c]), [&](int x, int y){ return a[x].y < a[y].y; }); if (sz(col[c]) == 3) { swap(col[c][1], col[c][2]); int t = col[c].back(); col[c].pop_back(); int nw = a[t].y; int &l = b[nw].fi, &r = b[nw].se; if (row[nw][l] == t) { ++l; if (l<r) _fill(nw, row[nw][l]); } else { --r; if (r>l) _fill(nw, row[nw][r]); } } } void main_code() { int n; cin >> n; vec<int> yy; for(int i = 0; i < n; ++i) { cin >> a[i].x >> a[i].y; row[a[i].y].push_back(i); } const int MAX = N - 3; FOR(i, 0, MAX) if (sz(row[i])) { sort(row[i].begin(), row[i].end(), [&](int x, int y) { return a[x].x < a[y].x; }); int m = sz(row[i]); b[i] = _mp(0, m - 1); _fill(i, row[i][0]); if (m != 1) _fill(i, row[i][m - 1]); } vec<bool> use(n, 0); FOR(i, 0, MAX) if (sz(row[i])) { int l=b[i].fi, r=b[i].se; if (l<=r){ use[row[i][l]]=use[row[i][r]]=1; } } string s; FOR(i,0,n-1){ if(use[i])s.push_back('1'); else s.push_back('0'); } cout << s; } /* Let the river flows naturally */

컴파일 시 표준 에러 (stderr) 메시지

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