답안 #243628

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
243628 2020-07-01T12:43:32 Z uacoder123 이상한 기계 (APIO19_strange_device) C++14
0 / 100
528 ms 16920 KB
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define FOR(i,a,b) for (auto i = (a); i <= (b); ++i)
#define NFOR(i,a,b) for(auto i = (a); i >= (b); --i)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define mp(i,a) make_pair(i,a)
#define pb(a) push_back(a)
#define bit(x,b) (x&(1LL<<b))
 
typedef long long int lli;
typedef pair <lli,lli> ii;
typedef pair <lli,ii> iii;
typedef vector <lli> vi;

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  lli test=1;
  for(;test>0;--test)
  {
    lli n,a,b,g,p,f,s,cl,cr,ans=0,ch=1;
    cin>>n>>a>>b;
    g=__gcd(a,b+1);
    g=a/g;
    if(1.0*g*b>1000000000000000000)
      p=1000000000500000000;
    else
      p=g*b;
    vector<ii> v;
    for(lli i=0;i<n;++i)
    {
      cin>>f>>s;
      if(f-s+1>=p)
      {
        cout<<p<<endl;
        ch=0;
      }
      f%=p;
      s%=p;
      if(f<=s)
        v.pb(mp(f,s));
      else
      {
        v.pb(mp(0,s));
        v.pb(mp(f,p-1));
      }
    }
    if(ch==0)
      exit(0);
    sort(all(v));
    v.pb(mp(p,p));
    cl=0;
    cr=-1;
    ans=0;
    for(lli i=0;i<v.size();++i)
    {
      if(v[i].F<=cr&&v[i].S>=cr)
      {
        cr=v[i].S;
      }
      else
      {
        ans+=cr-cl+1;
        cl=v[i].F;
        cr=v[i].S;
      }
    }
    cout<<ans<<endl;
  }
  return(0);
}

Compilation message

strange_device.cpp: In function 'int main()':
strange_device.cpp:59:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(lli i=0;i<v.size();++i)
                 ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 10 ms 768 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB Output is correct
2 Incorrect 4 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 5 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 528 ms 16920 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 528 ms 16920 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 528 ms 16920 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Incorrect 61 ms 2536 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 10 ms 768 KB Output isn't correct
3 Halted 0 ms 0 KB -