| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1368258 | husseinjuanda | Strange Device (APIO19_strange_device) | C++20 | 365 ms | 93896 KiB |
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, A, B; cin >> n >> A >> B;
vector<pair<int, int>> seg(n);
int sum = 0;
for(auto &i : seg){
cin >> i.first >> i.second;
sum += i.second - i.first + 1;
}
if(n == 1){
int l = seg[0].first;
int r = seg[0].second;
int j = lcm(A, B+1);
if(j < 0 || j%A != 0 || j%(B+1) != 0){
cout << r-l+1 << "\n";
return 0;
}
j = j/(B+1);
cout << min(j*B, r-l+1) << "\n";
return 0;
}
if(sum <= 1e6){
int t = 0;
map<pair<int, int>, bool> m;
for(auto y : seg){
for(int i = y.first; i <= y.second; i++){
m[{(i+i/B)%A, {i%B}}] = true;
}
}
cout << m.size() << "\n";
return 0;
}
if(A*B <= 1e6 && A < 1e10/B){
int j = lcm(A, B+1);
j/=(B+1);
j*=B;
vector<int> f(2*j+2);
for(auto y : seg){
if(y.second-y.first+1 >= j){
cout << j << "\n";
return 0;
}else{
if(y.first%j < y.second%j){
f[y.first%j]++;
f[y.second%j+1]--;
}else{
f[y.first%j]++;
f[j+(y.second%j)+1]--;
}
}
}
map<int, bool> j1;
int co = 0;
for(int i = 0; i < 2*j; i++){
co += f[i];
if(co > 0){
j1[i%j] = true;
}
}
cout << j1.size() << "\n";
return 0;
}
return 0;
}| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
