Submission #723176

#TimeUsernameProblemLanguageResultExecution timeMemory
723176culver0412Strange Device (APIO19_strange_device)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; int main(){ long long int n,a,b; cin >> n >> a >> b; long long int x=a/gcd(a,b+1)*b; pair<long long int,long long int> ranges; for(int i=0;i<n;i++){ long long int l,r; cin >> l >> r; if(r-l+1>=x){ cout << x << endl return 0; } l%=x; r%=x; if(l<=r){ ranges.push_back({l,r}); } else{ ranges.push_back({0,r}); ranges.push_back({l,x-1}); } } sort(ranges.begin(),ranges.end()); long long int curl=ranges[0].first,curr=ranges[0].second,ans=0; for(int i=1;i<ranges.size();i++){ pair<long long int,long long int> range=ranges[i]; if(curr<range.first){ ans+=(curr-curl+1); curl=range.first; curr=range.second; } else{ curr=max(curr,range.second); } } ans+=(curr-curl+1); cout << ans << endl; }

Compilation message (stderr)

strange_device.cpp: In function 'int main()':
strange_device.cpp:13:30: error: expected ';' before 'return'
   13 |             cout << x << endl
      |                              ^
      |                              ;
   14 |             return 0;
      |             ~~~~~~            
strange_device.cpp:19:20: error: 'struct std::pair<long long int, long long int>' has no member named 'push_back'
   19 |             ranges.push_back({l,r});
      |                    ^~~~~~~~~
strange_device.cpp:22:20: error: 'struct std::pair<long long int, long long int>' has no member named 'push_back'
   22 |             ranges.push_back({0,r});
      |                    ^~~~~~~~~
strange_device.cpp:23:20: error: 'struct std::pair<long long int, long long int>' has no member named 'push_back'
   23 |             ranges.push_back({l,x-1});
      |                    ^~~~~~~~~
strange_device.cpp:26:17: error: 'struct std::pair<long long int, long long int>' has no member named 'begin'
   26 |     sort(ranges.begin(),ranges.end());
      |                 ^~~~~
strange_device.cpp:26:32: error: 'struct std::pair<long long int, long long int>' has no member named 'end'
   26 |     sort(ranges.begin(),ranges.end());
      |                                ^~~
strange_device.cpp:27:30: error: no match for 'operator[]' (operand types are 'std::pair<long long int, long long int>' and 'int')
   27 |     long long int curl=ranges[0].first,curr=ranges[0].second,ans=0;
      |                              ^
strange_device.cpp:28:26: error: 'struct std::pair<long long int, long long int>' has no member named 'size'
   28 |     for(int i=1;i<ranges.size();i++){
      |                          ^~~~
strange_device.cpp:29:55: error: no match for 'operator[]' (operand types are 'std::pair<long long int, long long int>' and 'int')
   29 |         pair<long long int,long long int> range=ranges[i];
      |                                                       ^
strange_device.cpp:30:12: error: 'curr' was not declared in this scope; did you mean 'curl'?
   30 |         if(curr<range.first){
      |            ^~~~
      |            curl
strange_device.cpp:31:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
   31 |             ans+=(curr-curl+1);
      |             ^~~
      |             abs
strange_device.cpp:39:5: error: 'ans' was not declared in this scope; did you mean 'abs'?
   39 |     ans+=(curr-curl+1);
      |     ^~~
      |     abs
strange_device.cpp:39:11: error: 'curr' was not declared in this scope; did you mean 'curl'?
   39 |     ans+=(curr-curl+1);
      |           ^~~~
      |           curl