Submission #974643

# Submission time Handle Problem Language Result Execution time Memory
974643 2024-05-03T14:55:01 Z Abito Strange Device (APIO19_strange_device) C++17
5 / 100
526 ms 131904 KB
#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define ppb pop_back
#define ep insert
#define endl '\n'
#define elif else if
#define pow pwr
#define sqrt sqrtt
#define int long long
#define ll long long
typedef unsigned long long ull;
using namespace std;
const int N=1e6+5;
int n,a,b,l[N],r[N];
int32_t main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    cin>>n>>a>>b;
    if (!(a&1)) a/=2;
    for (int i=1;i<=n;i++) cin>>l[i]>>r[i];
    vector<pair<int,int>> v;
    for (int i=1;i<=n;i++){
        if (r[i]-l[i]+1>=a) v.pb({0,a-1});
        else{
            int L=l[i]%a;
            if ((L+r[i]-l[i])%a>=L) v.pb({L,(L+r[i]-l[i])%a});
            else{
                v.pb({L,a-1});
                v.pb({0,(L+r[i]-l[i])%a});
            }
        }
    }
    sort(v.begin(),v.end());
    //for (auto u:v) cout<<u.F<<' '<<u.S<<endl;
    set<pair<int,int>> s;
    pair<int,int> cur=v[0];
    for (int i=0;i<v.size();i++){
        int l=max(cur.F,v[i].F),r=min(cur.S,v[i].S);
        if (l>r){
            s.ep(cur);
            cur=v[i];
        }
        else{
            cur.F=min(cur.F,v[i].F);
            cur.S=max(cur.S,v[i].S);
        }
    }
    s.ep(cur);
    int ans=0;
    for (auto u:s) ans+=u.S-u.F+1;
    cout<<ans<<endl;
    return 0;
}

Compilation message

strange_device.cpp: In function 'int32_t main()':
strange_device.cpp:38:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |     for (int i=0;i<v.size();i++){
      |                  ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Incorrect 5 ms 2908 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Incorrect 2 ms 2396 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Incorrect 1 ms 2396 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 511 ms 94168 KB Output is correct
3 Correct 517 ms 131904 KB Output is correct
4 Correct 526 ms 131392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 511 ms 94168 KB Output is correct
3 Correct 517 ms 131904 KB Output is correct
4 Correct 526 ms 131392 KB Output is correct
5 Correct 1 ms 2648 KB Output is correct
6 Incorrect 341 ms 83628 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 511 ms 94168 KB Output is correct
3 Correct 517 ms 131904 KB Output is correct
4 Correct 526 ms 131392 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Incorrect 32 ms 12656 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Incorrect 40 ms 9092 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Incorrect 5 ms 2908 KB Output isn't correct
3 Halted 0 ms 0 KB -