제출 #409882

#제출 시각아이디문제언어결과실행 시간메모리
409882yoavL이상한 기계 (APIO19_strange_device)C++14
5 / 100
5025 ms266660 KiB
#include <iostream> #include <vector> #include <algorithm> #include <string> #include <set> #include <unordered_set> #include <map> #include <unordered_map> #include <queue> #include <stack> #include <bitset> #include <math.h> #include <fstream> #include <iomanip> using namespace std; using ll = long long; using ld = long double; using vll = vector<ll>; using vvll = vector<vll>; using vvvll = vector<vvll>; using vvvvll = vector<vvvll>; using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>; using vld = vector<ld>; using vvld = vector<vld>; using vstr = vector<string>; using pll = pair<ll, ll>; using vpll = vector<pll>; using vvpll = vector<vpll>; using pb = pair<bool, bool>; using vpb = vector<pb>; using vvpb = vector<vpb>; using vi = vector<int>; using vvi = vector<vi>; const ll mod = (ll)1e9 + 7; const ll inf = (ll)1e18; #define FAST ios_base::sync_with_stdio(0) #define FASTIN cin.tie(0) #define FASTOUT cout.tie(0) #define upmin(a, b) a = min(a, b) #define upmax(a, b) a = max(a, b) #define pr(x) cout << x << endl; #define prv(v) cout << #v << ": "; for(auto it = v.begin(); it != v.end(); ++it) cout << *it << " "; cout << endl; #define prvv(v) for(auto it : v) { for(auto it2 : it) cout << it2 << " "; cout << endl; } cout << endl; #define wpr(x) cout << #x << " = " << (x) << endl; #define wprv(v) cout << #v << ": " << endl; for(auto it : v) cout << *it << " "; cout << endl; #define wprvv(v) cout << #v << ": " << endl; for(auto it : v) { for(auto it2 : it) cout << it2 << " "; cout << endl; } cout << endl; #define rep(i,s,e) for(ll i = s; i < e; i++) #define all(x) x.begin(),x.end() #define pb push_back ll n, A, B; struct SEG { vb a; ll sz; void make(ll n) { for (sz = 1; sz < n; sz <<= 1); a.resize(sz * 2, 0); } void up(ll l, ll r) { l += sz, r += sz; while (l <= r) { if (l % 2 == 1) a[l++] = 1; if (r % 2 == 0) a[r--] = 1; l >>= 1, r >>= 1; } } ll get(ll i) { for (i += sz; i; i >>= 1) { if (a[i]) return 1; } return 0; } ll q(ll l, ll r) { l += sz, r += sz; ll res = 0; while (l <= r) { if (l % 2 == 1) res |= a[l++]; if (r % 2 == 0) res |= a[r--]; l >>= 1, r >>= 1; } return res; } }; ll x(ll t) { return (t + t / B) % A; } ll y(ll t) { return t % B; } void solve() { cin >> n >> A >> B; SEG seg; seg.make(A * B); rep(i, 0, n) { ll l, r; cin >> l >> r; ll d = (r - l + 1); if (d >= A * B - 1) { seg.up(0, A * B - 1); continue; } l %= A * B; r %= A * B; if (l <= r) { seg.up(l, r); } else { seg.up(l, A * B - 1); seg.up(0, r); } } ll ans = 0; rep(i, 0, A* B) { ans += seg.get(i); } pr(ans); } int main() { FAST; FASTIN; FASTOUT; solve(); } /* 3 3 3 4 4 7 9 17 18 */
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...