Submission #782591

# Submission time Handle Problem Language Result Execution time Memory
782591 2023-07-14T06:16:52 Z andecaandeci Strange Device (APIO19_strange_device) C++17
0 / 100
1 ms 212 KB
#include <bits/stdc++.h>
#define LL long long 
LL INF =1e18+5LL; 
using namespace std;
int main()
{
  LL n,a,b;
  cin>>n>>a>>b;
  LL t = (a/__gcd(b+1,a));

  vector<pair<LL,LL>>v;
  __int128_t x=(__int128_t)b*t;
  if(x>INF)t=INF;
  else t=(LL)x;

//  printf("t=%lld\n",t);
bool jawab=false;
  for(LL a=1;a<=n;a++)
  {
    LL l,r;
    cin>>l>>r;
    LL temp=l,temp2=r;
    if(l-r+1>=t)
    {
      printf("%lld",t);
      jawab=1;
      continue;
  }
  if(jawab)continue;
    l%=t ,r%=t;
    if(l==r)
    {
      if(temp==temp2)
      {
        v.push_back(make_pair(l,0));
        v.push_back(make_pair(r,1));
      }
      else
      {
        v.push_back(make_pair(0,0));
        v.push_back(make_pair(t-1,1));
       } 
    }
    else if(l>r)
    {
  //    printf("->%lld,%lld\n-> 0 %lld\n",l,t-1,r);
    //  v.push_back(make_pair(l,t-1));
      v.push_back(make_pair(l,0));
      v.push_back(make_pair(t-1,1));
    //  v.push_back(make_pair(0,r));
      v.push_back(make_pair(0,0));
      v.push_back(make_pair(r,1));
    }
    else
    {
      v.push_back(make_pair(l,0));
        v.push_back(make_pair(r,1));
     } 

  }
  sort(v.begin(),v.end());
  LL kanan=0,tot=0,kiri=0,cnt=0;
  for(pair<LL,LL>x:v)
  {
    if(x.second==0)
    {
      cnt++;
      if(cnt==1)kiri=x.first;
    }
    else
    {
      cnt--;
      if(cnt==0)tot+=(x.first-kiri+1);
    }
  }
  cout<<tot<<endl;
}

Compilation message

strange_device.cpp: In function 'int main()':
strange_device.cpp:62:6: warning: unused variable 'kanan' [-Wunused-variable]
   62 |   LL kanan=0,tot=0,kiri=0,cnt=0;
      |      ^~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -