Submission #782571

# Submission time Handle Problem Language Result Execution time Memory
782571 2023-07-14T05:40:19 Z devariaota Strange Device (APIO19_strange_device) C++17
65 / 100
1275 ms 33688 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);
  for(LL a=1;a<=n;a++)
  {
    LL l,r;
    cin>>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:54:6: warning: unused variable 'kanan' [-Wunused-variable]
   54 |   LL kanan=0,tot=0,kiri=0,cnt=0;
      |      ^~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 11 ms 1040 KB Output is correct
3 Correct 12 ms 976 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 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 304 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 300 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 296 KB Output is correct
16 Correct 12 ms 944 KB Output is correct
17 Correct 125 ms 4920 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 212 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 2 ms 340 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Correct 2 ms 372 KB Output is correct
5 Correct 744 ms 33404 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 296 KB Output is correct
2 Correct 1103 ms 33284 KB Output is correct
3 Correct 1133 ms 33488 KB Output is correct
4 Correct 1078 ms 33544 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 296 KB Output is correct
2 Correct 1103 ms 33284 KB Output is correct
3 Correct 1133 ms 33488 KB Output is correct
4 Correct 1078 ms 33544 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1123 ms 33444 KB Output is correct
7 Correct 1139 ms 33408 KB Output is correct
8 Correct 1076 ms 33384 KB Output is correct
9 Correct 1151 ms 33316 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 296 KB Output is correct
2 Correct 1103 ms 33284 KB Output is correct
3 Correct 1133 ms 33488 KB Output is correct
4 Correct 1078 ms 33544 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 107 ms 4700 KB Output is correct
7 Correct 110 ms 4656 KB Output is correct
8 Correct 106 ms 4632 KB Output is correct
9 Correct 124 ms 4808 KB Output is correct
10 Correct 106 ms 4624 KB Output is correct
11 Correct 108 ms 4652 KB Output is correct
12 Correct 114 ms 4792 KB Output is correct
13 Correct 121 ms 4480 KB Output is correct
14 Correct 106 ms 4696 KB Output is correct
15 Correct 113 ms 4660 KB Output is correct
16 Correct 111 ms 4576 KB Output is correct
17 Correct 124 ms 4628 KB Output is correct
18 Correct 1176 ms 33488 KB Output is correct
19 Correct 1082 ms 33212 KB Output is correct
20 Correct 1208 ms 33688 KB Output is correct
21 Correct 112 ms 4628 KB Output is correct
22 Correct 105 ms 4588 KB Output is correct
23 Correct 355 ms 17204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 111 ms 4616 KB Output is correct
3 Correct 110 ms 4628 KB Output is correct
4 Correct 1275 ms 33448 KB Output is correct
5 Correct 114 ms 4728 KB Output is correct
6 Correct 113 ms 4520 KB Output is correct
7 Correct 118 ms 4656 KB Output is correct
8 Correct 123 ms 4616 KB Output is correct
9 Correct 112 ms 4648 KB Output is correct
10 Correct 121 ms 4576 KB Output is correct
11 Correct 113 ms 4596 KB Output is correct
12 Correct 106 ms 4504 KB Output is correct
13 Correct 111 ms 4648 KB Output is correct
14 Correct 1153 ms 33372 KB Output is correct
15 Correct 116 ms 4672 KB Output is correct
16 Correct 1072 ms 33268 KB Output is correct
17 Correct 1082 ms 33636 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 11 ms 1040 KB Output is correct
3 Correct 12 ms 976 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 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 304 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 300 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 296 KB Output is correct
16 Correct 12 ms 944 KB Output is correct
17 Correct 125 ms 4920 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 212 KB Output isn't correct
21 Halted 0 ms 0 KB -