Submission #782540

# Submission time Handle Problem Language Result Execution time Memory
782540 2023-07-14T04:41:56 Z kebine Strange Device (APIO19_strange_device) C++17
65 / 100
596 ms 36444 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));
  if(t<0)t=1e18+5;
  vector<pair<LL,LL>>v;
//  printf("t=%lld\n",t);
  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,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:49:6: warning: unused variable 'kanan' [-Wunused-variable]
   49 |   LL kanan=0,tot=0,kiri=0,cnt=0;
      |      ^~~~~
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:15:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |     scanf("%lld %lld",&l,&r);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 6 ms 1276 KB Output is correct
3 Correct 5 ms 1208 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 296 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 300 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 296 KB Output is correct
15 Correct 1 ms 296 KB Output is correct
16 Correct 5 ms 1232 KB Output is correct
17 Correct 62 ms 6168 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 304 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 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 368 KB Output is correct
5 Correct 294 ms 33356 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 489 ms 33296 KB Output is correct
3 Correct 483 ms 36284 KB Output is correct
4 Correct 488 ms 36284 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 489 ms 33296 KB Output is correct
3 Correct 483 ms 36284 KB Output is correct
4 Correct 488 ms 36284 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 579 ms 36396 KB Output is correct
7 Correct 555 ms 36096 KB Output is correct
8 Correct 482 ms 35844 KB Output is correct
9 Correct 573 ms 36376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 489 ms 33296 KB Output is correct
3 Correct 483 ms 36284 KB Output is correct
4 Correct 488 ms 36284 KB Output is correct
5 Correct 1 ms 300 KB Output is correct
6 Correct 49 ms 6776 KB Output is correct
7 Correct 52 ms 6868 KB Output is correct
8 Correct 50 ms 6804 KB Output is correct
9 Correct 50 ms 6828 KB Output is correct
10 Correct 44 ms 6840 KB Output is correct
11 Correct 51 ms 6824 KB Output is correct
12 Correct 46 ms 6824 KB Output is correct
13 Correct 57 ms 6852 KB Output is correct
14 Correct 54 ms 6816 KB Output is correct
15 Correct 49 ms 6832 KB Output is correct
16 Correct 54 ms 6844 KB Output is correct
17 Correct 52 ms 6764 KB Output is correct
18 Correct 496 ms 36380 KB Output is correct
19 Correct 455 ms 35740 KB Output is correct
20 Correct 540 ms 36444 KB Output is correct
21 Correct 52 ms 6756 KB Output is correct
22 Correct 43 ms 6752 KB Output is correct
23 Correct 117 ms 19904 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 46 ms 6528 KB Output is correct
3 Correct 47 ms 6704 KB Output is correct
4 Correct 596 ms 36420 KB Output is correct
5 Correct 46 ms 6816 KB Output is correct
6 Correct 46 ms 6768 KB Output is correct
7 Correct 49 ms 6804 KB Output is correct
8 Correct 48 ms 6752 KB Output is correct
9 Correct 60 ms 6708 KB Output is correct
10 Correct 64 ms 6788 KB Output is correct
11 Correct 48 ms 6740 KB Output is correct
12 Correct 41 ms 6752 KB Output is correct
13 Correct 49 ms 6752 KB Output is correct
14 Correct 486 ms 36052 KB Output is correct
15 Correct 56 ms 6860 KB Output is correct
16 Correct 442 ms 35248 KB Output is correct
17 Correct 472 ms 36432 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 6 ms 1276 KB Output is correct
3 Correct 5 ms 1208 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 296 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 300 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 296 KB Output is correct
15 Correct 1 ms 296 KB Output is correct
16 Correct 5 ms 1232 KB Output is correct
17 Correct 62 ms 6168 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Incorrect 1 ms 304 KB Output isn't correct
21 Halted 0 ms 0 KB -