제출 #461223

#제출 시각아이디문제언어결과실행 시간메모리
461223dxz05거래 (IZhO13_trading)C++14
100 / 100
260 ms18624 KiB
#pragma GCC optimize("Ofast,O2,O3") #pragma GCC target("avx2") #include <bits/stdc++.h> using namespace std; void debug_out() { cerr << endl; } template<typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << "[" << H << "]"; debug_out(T...); } #ifdef dddxxz #define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__) #else #define debug(...) 42 #endif #define SZ(s) ((int)s.size()) #define all(x) (x).begin(), (x).end() #define revall(x) (x).rbegin(), (x).rend() clock_t startTime; double getCurrentTime() { return (double) (clock() - startTime) / CLOCKS_PER_SEC; } #define MP make_pair typedef long long ll; mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count()); const double eps = 0.00001; const int MOD = 1e9; const int INF = 1000000101; const long long LLINF = 1223372000000000555; const int N = 5e5 + 3e2; const int M = 5522; int n, m; int t[N * 4]; void build(int v = 1, int tl = 1, int tr = n){ if (tl == tr){ t[v] = 1; return; } int tm = (tl + tr) >> 1; build(v + v, tl, tm); build(v + v + 1, tm + 1, tr); t[v] = t[v + v] + t[v + v + 1]; } void update(int pos, int v = 1, int tl = 1, int tr = n){ if (tl == tr){ t[v] = 0; return; } int tm = (tl + tr) >> 1; if (pos <= tm) update(pos, v + v, tl, tm); else update(pos, v + v + 1, tm + 1, tr); t[v] = t[v + v] + t[v + v + 1]; } int find(int k, int v = 1, int tl = 1, int tr = n){ if (k > t[v]) return n + 1; if (tl == tr) return tl; int tm = (tl + tr) >> 1; if (t[v + v] >= k) return find(k, v + v, tl, tm); else return find(k - t[v + v], v + v + 1, tm + 1, tr); } int f[N]; void add(int x, int y){ while (x < N){ f[x] += y; x += (-x & x); } } int get(int x){ int res = 0; while (x > 0){ res += f[x]; x -= (-x & x); } return res; } int ans[N]; int lf[N], rg[N], val[N]; void solve(int TC) { cin >> n >> m; vector<int> perm(m); for (int i = 1; i <= m; i++){ cin >> lf[i] >> rg[i] >> val[i]; perm[i - 1] = i; } for (int i = 1; i <= n; i++){ add(i, 1); } build(); sort(all(perm), [](int i, int j){ return val[i] - lf[i] > val[j] - lf[j]; }); for (int i : perm){ debug(i); int cur = get(lf[i]); if (get(lf[i]) - get(lf[i] - 1) == 0) cur++; debug(cur); int ind = find(cur); while (ind <= rg[i]){ ans[ind] = val[i] + ind - lf[i]; update(ind); add(ind, -1); debug(cur, ind); ind = find(cur); } } for (int i = 1; i <= n; i++){ cout << ans[i] << ' '; } } int main() { startTime = clock(); cin.tie(nullptr); cout.tie(nullptr); ios_base::sync_with_stdio(false); bool llololcal = false; #ifdef dddxxz freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); llololcal = true; #endif int TC = 1; //cin >> TC; for (int test = 1; test <= TC; test++) { debug(test); //cout << "Case #" << test << ": "; solve(test); } if (llololcal) cerr << endl << "Time: " << int(getCurrentTime() * 1000) << " ms" << endl; return 0; }

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

trading.cpp: In function 'void solve(int)':
trading.cpp:19:20: warning: statement has no effect [-Wunused-value]
   19 | #define debug(...) 42
      |                    ^~
trading.cpp:121:9: note: in expansion of macro 'debug'
  121 |         debug(i);
      |         ^~~~~
trading.cpp:19:20: warning: statement has no effect [-Wunused-value]
   19 | #define debug(...) 42
      |                    ^~
trading.cpp:125:9: note: in expansion of macro 'debug'
  125 |         debug(cur);
      |         ^~~~~
trading.cpp:19:20: warning: statement has no effect [-Wunused-value]
   19 | #define debug(...) 42
      |                    ^~
trading.cpp:133:13: note: in expansion of macro 'debug'
  133 |             debug(cur, ind);
      |             ^~~~~
trading.cpp: In function 'int main()':
trading.cpp:19:20: warning: statement has no effect [-Wunused-value]
   19 | #define debug(...) 42
      |                    ^~
trading.cpp:162:9: note: in expansion of macro 'debug'
  162 |         debug(test);
      |         ^~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...