Submission #782548

# Submission time Handle Problem Language Result Execution time Memory
782548 2023-07-14T04:57:15 Z christinelynn Strange Device (APIO19_strange_device) C++17
65 / 100
1229 ms 34500 KB
#include <bits/stdc++.h>
#define LL long long int 
using namespace std;
int main()
{
  LL n,a,b;
  cin>>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;
    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:49:6: warning: unused variable 'kanan' [-Wunused-variable]
   49 |   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 1280 KB Output is correct
3 Correct 12 ms 1232 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 304 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 296 KB Output is correct
14 Correct 1 ms 300 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 12 ms 1232 KB Output is correct
17 Correct 118 ms 5620 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 0 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 1 ms 312 KB Output is correct
4 Correct 2 ms 340 KB Output is correct
5 Correct 747 ms 33276 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1133 ms 33272 KB Output is correct
3 Correct 1124 ms 34064 KB Output is correct
4 Correct 1096 ms 34008 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1133 ms 33272 KB Output is correct
3 Correct 1124 ms 34064 KB Output is correct
4 Correct 1096 ms 34008 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1114 ms 33968 KB Output is correct
7 Correct 1105 ms 33848 KB Output is correct
8 Correct 1098 ms 33924 KB Output is correct
9 Correct 1156 ms 33988 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1133 ms 33272 KB Output is correct
3 Correct 1124 ms 34064 KB Output is correct
4 Correct 1096 ms 34008 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 108 ms 5508 KB Output is correct
7 Correct 112 ms 5264 KB Output is correct
8 Correct 119 ms 5324 KB Output is correct
9 Correct 110 ms 5320 KB Output is correct
10 Correct 107 ms 5256 KB Output is correct
11 Correct 113 ms 5224 KB Output is correct
12 Correct 107 ms 5176 KB Output is correct
13 Correct 111 ms 5276 KB Output is correct
14 Correct 106 ms 5160 KB Output is correct
15 Correct 127 ms 5224 KB Output is correct
16 Correct 112 ms 5240 KB Output is correct
17 Correct 116 ms 5260 KB Output is correct
18 Correct 1111 ms 34180 KB Output is correct
19 Correct 1083 ms 33936 KB Output is correct
20 Correct 1187 ms 34480 KB Output is correct
21 Correct 118 ms 5332 KB Output is correct
22 Correct 104 ms 5436 KB Output is correct
23 Correct 333 ms 18072 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 111 ms 5048 KB Output is correct
3 Correct 114 ms 5364 KB Output is correct
4 Correct 1229 ms 34460 KB Output is correct
5 Correct 112 ms 5280 KB Output is correct
6 Correct 112 ms 5296 KB Output is correct
7 Correct 123 ms 5356 KB Output is correct
8 Correct 119 ms 5312 KB Output is correct
9 Correct 112 ms 5424 KB Output is correct
10 Correct 115 ms 5348 KB Output is correct
11 Correct 115 ms 5336 KB Output is correct
12 Correct 104 ms 5252 KB Output is correct
13 Correct 114 ms 5408 KB Output is correct
14 Correct 1167 ms 34496 KB Output is correct
15 Correct 114 ms 5252 KB Output is correct
16 Correct 1061 ms 33740 KB Output is correct
17 Correct 1081 ms 34500 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 1280 KB Output is correct
3 Correct 12 ms 1232 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 304 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 296 KB Output is correct
14 Correct 1 ms 300 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 12 ms 1232 KB Output is correct
17 Correct 118 ms 5620 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Incorrect 0 ms 212 KB Output isn't correct
21 Halted 0 ms 0 KB -