Submission #267717

# Submission time Handle Problem Language Result Execution time Memory
267717 2020-08-16T05:43:55 Z kkm0476 Strange Device (APIO19_strange_device) C++
0 / 100
3453 ms 263916 KB
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>

using namespace std;


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

int main() {
    scanf("%d %d %d", &n, &A, &B);
    
    for(int i = 0; i < n; i++) {
        int l, r;
        scanf("%d %d", &l, &r);
        for(int t = l; t <= r; t++) {
            int x = (t + (int)((double)t / B)) % A;
            int y = t % B;
            v.push_back({x, y});
        }
    }
    
    int ret = 0;
    sort(v.begin(), v.end());
    for(int 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("%d", ret);
    
    return 0;
}

Compilation message

strange_device.cpp: In function 'int main()':
strange_device.cpp:27:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |     for(int i = 0; i < v.size(); i++) {
      |                    ~~^~~~~~~~~~
strange_device.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   13 |     scanf("%d %d %d", &n, &A, &B);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
strange_device.cpp:17:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   17 |         scanf("%d %d", &l, &r);
      |         ~~~~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Incorrect 27 ms 2932 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Incorrect 1 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Incorrect 71 ms 8684 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Incorrect 552 ms 8656 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Incorrect 552 ms 8656 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Incorrect 552 ms 8656 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Incorrect 3453 ms 263916 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Incorrect 27 ms 2932 KB Output isn't correct
3 Halted 0 ms 0 KB -