Submission #782451

# Submission time Handle Problem Language Result Execution time Memory
782451 2023-07-14T02:02:42 Z makanhulia Strange Device (APIO19_strange_device) C++17
10 / 100
418 ms 33264 KB
#include <bits/stdc++.h>
#define LL long long 
using namespace std;
int main()
{
  LL n,a,b;
  scanf("%lld %lld %lld",&n,&a,&b);
  LL t=b*(a/__gcd(b+1,a));
  vector<pair<LL,LL>>v;
  for(LL a=1;a<=n;a++)
  {
    LL l,r;
    scanf("%lld %lld",&l,&r);
    LL temp=l,temp2=r;
    l%=t ,r%=t;
    if(l==r)
    {
      if(temp==temp2)v.push_back(make_pair(l,r));
      else v.push_back(make_pair(0,t-1));
    }
    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(0,r));
    }
    else v.push_back(make_pair(l,r));
  }
  sort(v.begin(),v.end());
  LL kanan=0,tot=0,kiri=0;
  for(pair<LL,LL>x:v)
  {
  //  printf("%lld %lld %lld\n",x.first,x.second,tot);
    if(x.second>=kanan && (x.first<=kanan ))
    {
      kanan=x.second;
    }
    else if(kanan<x.first)
    {
      tot+=(kanan-kiri+1);
      kiri=x.first,kanan=x.second;
    }
  }
  tot+=(kanan-kiri+1);
  cout<<tot<<endl;
}

Compilation message

strange_device.cpp: In function 'int main()':
strange_device.cpp:7:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 |   scanf("%lld %lld %lld",&n,&a,&b);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
strange_device.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |     scanf("%lld %lld",&l,&r);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 4 ms 596 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 222 ms 16792 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 418 ms 33156 KB Output is correct
3 Correct 372 ms 16772 KB Output is correct
4 Correct 329 ms 16836 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 418 ms 33156 KB Output is correct
3 Correct 372 ms 16772 KB Output is correct
4 Correct 329 ms 16836 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 342 ms 16724 KB Output is correct
7 Correct 418 ms 33264 KB Output is correct
8 Correct 329 ms 16804 KB Output is correct
9 Incorrect 351 ms 16784 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 418 ms 33156 KB Output is correct
3 Correct 372 ms 16772 KB Output is correct
4 Correct 329 ms 16836 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 35 ms 2476 KB Output is correct
7 Correct 34 ms 2388 KB Output is correct
8 Correct 32 ms 2376 KB Output is correct
9 Correct 33 ms 2484 KB Output is correct
10 Correct 33 ms 2408 KB Output is correct
11 Correct 38 ms 2484 KB Output is correct
12 Correct 32 ms 2368 KB Output is correct
13 Incorrect 35 ms 2440 KB Output isn't correct
14 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 38 ms 2448 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 4 ms 596 KB Output isn't correct
3 Halted 0 ms 0 KB -