제출 #605186

#제출 시각아이디문제언어결과실행 시간메모리
605186thezomb1eICC (CEOI16_icc)C++17
61 / 100
167 ms492 KiB
#include "icc.h" #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define eb emplace_back #define pb push_back #define ft first #define sd second #define pi pair<int, int> #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define dbg(...) dbg_out(__VA_ARGS__) using ll = long long; using ld = long double; using namespace std; using namespace __gnu_pbds; //Constants const ll INF = 5 * 1e18; const int IINF = 2 * 1e9; const ll MOD = 1e9 + 7; // const ll MOD = 998244353; const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1}; const ld PI = 3.14159265359; //Templates template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) {return os << '(' << p.first << ", " << p.second << ')';} template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) {os << '['; string sep; for (const T &x : v) os << sep << x, sep = ", "; return os << ']';} void dbg_out() {cerr << endl;} template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << H << ' '; dbg_out(T...); } template<typename T> void mins(T& x, T y) {x = min(x, y);} template<typename T> void maxs(T& x, T y) {x = max(x, y);} template<typename T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; template<typename T> using omset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>; //order_of_key(k): number of elements strictly less than k //find_by_order(k): k-th element in the set void setPrec() {cout << fixed << setprecision(15);} void unsyncIO() {cin.tie(0)->sync_with_stdio(0);} void setIn(string s) {freopen(s.c_str(), "r", stdin);} void setOut(string s) {freopen(s.c_str(), "w", stdout);} void setIO(string s = "") { unsyncIO(); setPrec(); if(s.size()) setIn(s + ".in"), setOut(s + ".out"); } struct DSU { vector<int> e; DSU(int n) : e(n + 5, -1) {} int get(int x) {return e[x] <= -1 ? x : e[x] = get(e[x]);} bool unite(int x, int y) { x = get(x), y = get(y); if (x == y) return false; if (-e[x] < -e[y]) swap(x, y); e[x] += e[y]; e[y] = x; return true; } }; bool ask(vector<int> &l, vector<int> &r) { int sz_left = l.size(), sz_right = r.size(); int left[sz_left], right[sz_right]; for (int i = 0; i < sz_left; i++) { left[i] = l[i]; } for (int i = 0; i < sz_right; i++) { right[i] = r[i]; } return query(sz_left, sz_right, left, right); } void run(int n) { DSU dsu(n + 5); for(int _i = 0; _i < n - 1; _i++) { vector<vector<int>> comps; for (int i = 1; i <= n; i++) { vector<int> cur; for (int j = 1; j <= n; j++) { if (dsu.get(j) == i) { cur.pb(j); } } if (!cur.empty()) { comps.pb(cur); } } bool ok = false; vector<int> left, right; while (!ok) { random_shuffle(all(comps)); left.clear(); right.clear(); int c_size = comps.size(); for (int i = 0; i < c_size / 2; i++) { for (int x : comps[i]) { left.pb(x); } } for (int i = c_size / 2; i < c_size; i++) { for (int x : comps[i]) { right.pb(x); } } ok = ask(left, right); } int u = -1, v = -1; { int lo = 0, hi = (int) left.size() - 1; while (lo <= hi) { int mi = (lo + hi) / 2; vector<int> nw; for (int i = 0; i <= mi; i++) { nw.pb(left[i]); } if (ask(nw, right)) { u = mi; hi = mi - 1; } else { lo = mi + 1; } } } { int lo = 0, hi = (int) right.size() - 1; while (lo <= hi) { int mi = (lo + hi) / 2; vector<int> nw; for (int i = 0; i <= mi; i++) { nw.pb(right[i]); } if (ask(left, nw)) { v = mi; hi = mi - 1; } else { lo = mi + 1; } } } u = left[u]; v = right[v]; setRoad(u, v); dsu.unite(u, v); } }

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

icc.cpp: In function 'void setIn(std::string)':
icc.cpp:43:30: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   43 | void setIn(string s) {freopen(s.c_str(), "r", stdin);}
      |                       ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
icc.cpp: In function 'void setOut(std::string)':
icc.cpp:44:31: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   44 | void setOut(string s) {freopen(s.c_str(), "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...