제출 #267731

#제출 시각아이디문제언어결과실행 시간메모리
267731kkm0476Strange Device (APIO19_strange_device)C++98
10 / 100
883 ms524292 KiB
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>

using namespace std;

typedef long long lint;

lint n, A, B;
vector<pair<lint, lint> > v;

int main() {
    scanf("%lld %lld %lld", &n, &A, &B);
    
    for(lint i = 0; i < n; i++) {
        lint l, r;
        scanf("%lld %lld", &l, &r);
        for(lint t = l; t <= r; t++) {
            lint x = (t + (t / B)) % A;
            lint y = t % B;
            v.push_back({x, y});
        }
    }
    
    lint ret = 0;
    sort(v.begin(), v.end());
    for(lint i = 0; i < v.size(); i++) {
        if(i == 0)
            ret++;
        else if(v[i].first != v[i - 1].first || v[i].second != v[i - 1].second)
                ret++;
    }
    
    printf("%lld", ret);
    
    return 0;
}

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

strange_device.cpp: In function 'int main()':
strange_device.cpp:28:23: warning: comparison of integer expressions of different signedness: 'lint' {aka 'long long int'} and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |     for(lint i = 0; i < v.size(); i++) {
      |                     ~~^~~~~~~~~~
strange_device.cpp:14:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   14 |     scanf("%lld %lld %lld", &n, &A, &B);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
strange_device.cpp:18:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   18 |         scanf("%lld %lld", &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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...