제출 #646968

#제출 시각아이디문제언어결과실행 시간메모리
646968dxz05Segments (IZhO18_segments)C++14
16 / 100
253 ms19600 KiB
//#pragma GCC optimize("Ofast,O2,O3,unroll-loops") //#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 lla(x) (x).rbegin(), (x).rend() #define bpc(x) __builtin_popcount(x) #define bpcll(x) __builtin_popcountll(x) #define MP make_pair clock_t startTime; int getCurrentTime() { return int((double) (clock() - startTime) / CLOCKS_PER_SEC * 1000); } mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count()); typedef long long ll; const int MOD = 1e9 + 7; const int INF = 1000000101; const long long LLINF = 1223372000000000555; const int N = 2e6 + 3e2; const int M = 5555; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; template<typename T> using indexed_multiset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; indexed_multiset<pair<int, int>> lfs, rgs; multiset<pair<int, int>> seg; vector<pair<int, int>> vec_seg; void add(int l, int r, int id){ seg.insert(MP(l, r)); vec_seg.emplace_back(l, r); lfs.insert(MP(l, id)); rgs.insert(MP(r, id)); } void del(int l, int r, int id){ seg.erase(seg.find(MP(l, r))); lfs.erase(lfs.find(MP(l, id))); rgs.erase(rgs.find(MP(r, id))); } int intersects(int l, int r){ int res = (int)seg.size(); int strictly_left = rgs.order_of_key(MP(l, 0)); // number of right-points with < l int strictly_right = lfs.size() - lfs.order_of_key(MP(r + 1, 0)); // number of left-points with > r return res - strictly_left - strictly_right; } void solve(int TC){ int n, t; cin >> n >> t; int lastans = 0; int next_id = 0; while (n--){ int op; cin >> op; if (op == 1){ int l, r; cin >> l >> r; l ^= (t * lastans); r ^= (t * lastans); if (l > r) swap(l, r); add(l, r, next_id); next_id++; debug('+', l, r); } if (op == 2){ int id; cin >> id; --id; int l = vec_seg[id].first, r = vec_seg[id].second; del(l, r, id); debug('-', l, r); } if (op == 3){ int l, r, k; cin >> l >> r >> k; l ^= (t * lastans); r ^= (t * lastans); if (l > r) swap(l, r); int ans = intersects(l, r); cout << ans << endl; lastans = ans; debug('?', l, r); } } } int main() { startTime = clock(); ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); #ifdef dddxxz freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif int TC = 1; //cin >> TC; for (int test = 1; test <= TC; test++) { //debug(test); //cout << "Case #" << test << ": "; solve(test); } #ifdef dddxxz cerr << endl << "Time: " << getCurrentTime() << " ms" << endl; #endif return 0; }

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

segments.cpp: In function 'void solve(int)':
segments.cpp:19:20: warning: statement has no effect [-Wunused-value]
   19 | #define debug(...) 42
      |                    ^~
segments.cpp:98:13: note: in expansion of macro 'debug'
   98 |             debug('+', l, r);
      |             ^~~~~
segments.cpp:19:20: warning: statement has no effect [-Wunused-value]
   19 | #define debug(...) 42
      |                    ^~
segments.cpp:107:13: note: in expansion of macro 'debug'
  107 |             debug('-', l, r);
      |             ^~~~~
segments.cpp:19:20: warning: statement has no effect [-Wunused-value]
   19 | #define debug(...) 42
      |                    ^~
segments.cpp:123:13: note: in expansion of macro 'debug'
  123 |             debug('?', l, r);
      |             ^~~~~
#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...