Submission #332968

#TimeUsernameProblemLanguageResultExecution timeMemory
332968leinad2Strange Device (APIO19_strange_device)C++14
15 / 100
288 ms83552 KiB
#include<bits/stdc++.h> #define int __int128 using namespace std; int n, i, j, k, a, b, x, A[500010][2], ans; int gcd(int a, int b) { if(b==0)return a; return gcd(b, a%b); } vector<pair<int, int> >v, V; main() { for(scanf("%lld %lld %lld", &n, &a, &b);i++<n;)scanf("%lld %lld", &A[i][0], &A[i][1]); x=(a*b)/(gcd(a, b+1)); for(i=0;i++<n;) { if(A[i][1]-A[i][0]>=x-1) { v.push_back({0, x-1}); } else { if(A[i][0]%x<=A[i][1]%x) { v.push_back({A[i][0]%x, A[i][1]%x}); } else { v.push_back({0, A[i][1]%x}); v.push_back({A[i][0]%x, x-1}); } } } sort(v.begin(), v.end()); for(i=0;i<v.size();i++) { if(V.size()==0)V.push_back(v[i]); else { if(V.back().second>=v[i].first) { if(V.back().second<v[i].second) { V.back().second=v[i].second; } } else { V.push_back(v[i]); } } } for(i=0;i<V.size();i++) { ans+=(V[i].second-V[i].first+1); } printf("%lld", ans); }

Compilation message (stderr)

strange_device.cpp:11:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   11 | main()
      |      ^
strange_device.cpp: In function 'int main()':
strange_device.cpp:13:19: warning: format '%lld' expects argument of type 'long long int*', but argument 2 has type '__int128*' [-Wformat=]
   13 |     for(scanf("%lld %lld %lld", &n, &a, &b);i++<n;)scanf("%lld %lld", &A[i][0], &A[i][1]);
      |                ~~~^             ~~
      |                   |             |
      |                   |             __int128*
      |                   long long int*
strange_device.cpp:13:24: warning: format '%lld' expects argument of type 'long long int*', but argument 3 has type '__int128*' [-Wformat=]
   13 |     for(scanf("%lld %lld %lld", &n, &a, &b);i++<n;)scanf("%lld %lld", &A[i][0], &A[i][1]);
      |                     ~~~^            ~~
      |                        |            |
      |                        |            __int128*
      |                        long long int*
strange_device.cpp:13:29: warning: format '%lld' expects argument of type 'long long int*', but argument 4 has type '__int128*' [-Wformat=]
   13 |     for(scanf("%lld %lld %lld", &n, &a, &b);i++<n;)scanf("%lld %lld", &A[i][0], &A[i][1]);
      |                          ~~~^           ~~
      |                             |           |
      |                             |           __int128*
      |                             long long int*
strange_device.cpp:13:62: warning: format '%lld' expects argument of type 'long long int*', but argument 2 has type '__int128*' [-Wformat=]
   13 |     for(scanf("%lld %lld %lld", &n, &a, &b);i++<n;)scanf("%lld %lld", &A[i][0], &A[i][1]);
      |                                                           ~~~^        ~~~~~~~~
      |                                                              |        |
      |                                                              |        __int128*
      |                                                              long long int*
strange_device.cpp:13:67: warning: format '%lld' expects argument of type 'long long int*', but argument 3 has type '__int128*' [-Wformat=]
   13 |     for(scanf("%lld %lld %lld", &n, &a, &b);i++<n;)scanf("%lld %lld", &A[i][0], &A[i][1]);
      |                                                                ~~~^             ~~~~~~~~
      |                                                                   |             |
      |                                                                   |             __int128*
      |                                                                   long long int*
strange_device.cpp:57:16: warning: format '%lld' expects argument of type 'long long int', but argument 2 has type '__int128' [-Wformat=]
   57 |     printf("%lld", ans);
      |             ~~~^   ~~~
      |                |   |
      |                |   __int128
      |                long long int
strange_device.cpp:13:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   13 |     for(scanf("%lld %lld %lld", &n, &a, &b);i++<n;)scanf("%lld %lld", &A[i][0], &A[i][1]);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
strange_device.cpp:13:57: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   13 |     for(scanf("%lld %lld %lld", &n, &a, &b);i++<n;)scanf("%lld %lld", &A[i][0], &A[i][1]);
      |                                                    ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...