답안 #660898

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
660898 2022-11-23T13:38:07 Z littlefermat 이상한 기계 (APIO19_strange_device) C++14
35 / 100
1427 ms 53408 KB
#include <bits/stdc++.h>
#define L first
#define R second
using namespace std;
typedef long long ll;

vector<pair<ll,ll> > v;

int main()
{
    ll e=pow(10,18)+1;
      ll n,A,B,x;
      cin>>n>>A>>B;
      ll j=n;
      A=A/__gcd(A,B+1);
      ll mod=A*B;

      for(long long i=0;i<n;i++){
        ll l,r;
        cin>>l>>r;
        if(r-l >= mod)
            cout<<mod<<endl,exit(0);
        l %= mod; r %= mod;
        if(l > r)
            v.push_back(make_pair(0,r)),
            v.push_back(make_pair(l,mod-1));
        else
            v.push_back(make_pair(l,r));
      }

      sort(v.begin(),v.end());
      for(int i = 0 ;i <v.size()-1; i++ ){

        if(v[i+1].L <= v[i].R ){
            if(v[i].R < v[i+1].R ){
                v[i+1].L = v[i].L , v[i].L=v[i].R+1;
            }
            else{
                v[i+1].L=v[i].L,v[i+1].R=v[i].R,v[i].L=v[i].R+1;
            }
        }
      }
      ll m=0;
      for(int i=0;i<v.size();i++)
        m += v[i].second - v[i].first+1;
      cout<<m<<"\n";
}

Compilation message

strange_device.cpp: In function 'int main()':
strange_device.cpp:32:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |       for(int i = 0 ;i <v.size()-1; i++ ){
      |                      ~~^~~~~~~~~~~
strange_device.cpp:44:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |       for(int i=0;i<v.size();i++)
      |                   ~^~~~~~~~~
strange_device.cpp:11:8: warning: unused variable 'e' [-Wunused-variable]
   11 |     ll e=pow(10,18)+1;
      |        ^
strange_device.cpp:12:16: warning: unused variable 'x' [-Wunused-variable]
   12 |       ll n,A,B,x;
      |                ^
strange_device.cpp:14:10: warning: unused variable 'j' [-Wunused-variable]
   14 |       ll j=n;
      |          ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 224 KB Output is correct
2 Correct 16 ms 1032 KB Output is correct
3 Correct 13 ms 980 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 296 KB Output is correct
8 Correct 1 ms 308 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 300 KB Output is correct
11 Correct 0 ms 300 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 1 ms 300 KB Output is correct
14 Correct 0 ms 300 KB Output is correct
15 Correct 1 ms 300 KB Output is correct
16 Correct 14 ms 944 KB Output is correct
17 Correct 131 ms 5792 KB Output is correct
18 Incorrect 0 ms 212 KB Output isn't correct
19 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 300 KB Output is correct
2 Correct 0 ms 304 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Incorrect 0 ms 292 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 2 ms 340 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Correct 2 ms 316 KB Output is correct
5 Correct 898 ms 41224 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1265 ms 19968 KB Output is correct
3 Correct 1254 ms 53356 KB Output is correct
4 Correct 1262 ms 53136 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1265 ms 19968 KB Output is correct
3 Correct 1254 ms 53356 KB Output is correct
4 Correct 1262 ms 53136 KB Output is correct
5 Correct 1 ms 300 KB Output is correct
6 Correct 1250 ms 53200 KB Output is correct
7 Correct 1427 ms 53188 KB Output is correct
8 Correct 1255 ms 53208 KB Output is correct
9 Correct 1271 ms 53388 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1265 ms 19968 KB Output is correct
3 Correct 1254 ms 53356 KB Output is correct
4 Correct 1262 ms 53136 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 137 ms 5800 KB Output is correct
7 Correct 127 ms 5648 KB Output is correct
8 Correct 125 ms 5700 KB Output is correct
9 Correct 131 ms 5620 KB Output is correct
10 Correct 130 ms 5592 KB Output is correct
11 Correct 125 ms 5676 KB Output is correct
12 Correct 125 ms 5688 KB Output is correct
13 Correct 130 ms 5632 KB Output is correct
14 Correct 128 ms 5664 KB Output is correct
15 Correct 131 ms 5664 KB Output is correct
16 Correct 126 ms 5696 KB Output is correct
17 Correct 129 ms 5624 KB Output is correct
18 Correct 1343 ms 53408 KB Output is correct
19 Correct 1249 ms 53176 KB Output is correct
20 Correct 1308 ms 53284 KB Output is correct
21 Correct 133 ms 5644 KB Output is correct
22 Correct 125 ms 5688 KB Output is correct
23 Correct 420 ms 18428 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 130 ms 5660 KB Output is correct
3 Correct 128 ms 5592 KB Output is correct
4 Correct 1332 ms 53288 KB Output is correct
5 Correct 127 ms 5632 KB Output is correct
6 Correct 127 ms 5648 KB Output is correct
7 Correct 128 ms 5572 KB Output is correct
8 Correct 152 ms 5696 KB Output is correct
9 Correct 127 ms 5588 KB Output is correct
10 Correct 130 ms 5656 KB Output is correct
11 Correct 147 ms 5668 KB Output is correct
12 Correct 127 ms 5680 KB Output is correct
13 Correct 130 ms 5664 KB Output is correct
14 Correct 1278 ms 53124 KB Output is correct
15 Correct 131 ms 5684 KB Output is correct
16 Correct 1261 ms 53216 KB Output is correct
17 Correct 1250 ms 53164 KB Output is correct
18 Incorrect 0 ms 212 KB Output isn't correct
19 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 224 KB Output is correct
2 Correct 16 ms 1032 KB Output is correct
3 Correct 13 ms 980 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 296 KB Output is correct
8 Correct 1 ms 308 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 300 KB Output is correct
11 Correct 0 ms 300 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 1 ms 300 KB Output is correct
14 Correct 0 ms 300 KB Output is correct
15 Correct 1 ms 300 KB Output is correct
16 Correct 14 ms 944 KB Output is correct
17 Correct 131 ms 5792 KB Output is correct
18 Incorrect 0 ms 212 KB Output isn't correct
19 Halted 0 ms 0 KB -