Submission #1101218

# Submission time Handle Problem Language Result Execution time Memory
1101218 2024-10-15T19:07:50 Z Raj Circle Passing (EGOI24_circlepassing) C++11
14 / 100
2000 ms 6272 KB
#include <bits/stdc++.h>
using namespace std;
int n,M,Q;
int v[1000001];
int stanga(int x,int y)
{
    if(x<y)
        return 2*n-y+x;
    else
        return x-y;
}
int dreapta(int x,int y)
{
    if(x>y)
        return 2*n-x+y;
    else
        return y-x;
}
int shc(int x, int y)
{
    int pas1=1;
    int pas4=1;
    int pas3=1;
    int pas2=1;
    int ok=0;
    int k=0;
    int t,mn=INT_MAX;

    for(int i=1;i<=M;++i)
    {
        int dist=0,dist1=0,dist2=0,dist3=0;
        k=v[i];

        int k1=0;
        if(k<n)
            k1=k+n;
        else
            k1=k-n;
        dist=stanga(x,k);
        dist1=dreapta(x,k);
        dist2=stanga(x,k1);
        dist3=dreapta(x,k1);

        dist=min(dist,dist1);
        dist1=min(dist2,dist3);

        if(dist>dist1)
        {
            dist=dist1;
            k=k1;
        }
        if(dist<mn)
        {
            mn=dist;
            t=k;
            pas1=dist;
            pas2=dist;
        }

    }
    if(t>=n)
    {
        t=t-n;
        pas1+=stanga(t,y)+1;
        pas2+=dreapta(t,y)+1;
    }
    else
    {
        t=t+n;
        pas1+=stanga(t,y)+1;
        pas2+=dreapta(t,y)+1;
    }
    return min(pas1,pas2);
}
int main()
{
    cin>>n>>M>>Q;
    for(int i=1;i<=M;++i)
    {
        cin>>v[i];
    }
    for(int i=1;i<=Q;++i)
    {
        int a,b;
        cin>>a>>b;
        cout<<min(shc(a,b),min(stanga(a,b),dreapta(a,b)))<<'\n';
    }
    return 0;
}

Compilation message

Main.cpp: In function 'int shc(int, int)':
Main.cpp:22:9: warning: unused variable 'pas4' [-Wunused-variable]
   22 |     int pas4=1;
      |         ^~~~
Main.cpp:23:9: warning: unused variable 'pas3' [-Wunused-variable]
   23 |     int pas3=1;
      |         ^~~~
Main.cpp:25:9: warning: unused variable 'ok' [-Wunused-variable]
   25 |     int ok=0;
      |         ^~
Main.cpp:69:10: warning: 't' may be used uninitialized in this function [-Wmaybe-uninitialized]
   69 |         t=t+n;
      |         ~^~~~
# Verdict Execution time Memory Grader output
1 Correct 42 ms 540 KB Output is correct
2 Correct 37 ms 340 KB Output is correct
3 Correct 34 ms 596 KB Output is correct
4 Correct 1 ms 508 KB Output is correct
5 Correct 36 ms 712 KB Output is correct
6 Correct 37 ms 856 KB Output is correct
7 Correct 39 ms 848 KB Output is correct
8 Correct 40 ms 916 KB Output is correct
9 Correct 54 ms 900 KB Output is correct
10 Correct 40 ms 892 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 2 ms 508 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Correct 2 ms 448 KB Output is correct
5 Incorrect 3 ms 340 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 2 ms 508 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Correct 2 ms 448 KB Output is correct
5 Incorrect 3 ms 340 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 37 ms 844 KB Output is correct
2 Correct 1 ms 504 KB Output is correct
3 Execution timed out 2064 ms 6272 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 42 ms 540 KB Output is correct
2 Correct 37 ms 340 KB Output is correct
3 Correct 34 ms 596 KB Output is correct
4 Correct 1 ms 508 KB Output is correct
5 Correct 36 ms 712 KB Output is correct
6 Correct 37 ms 856 KB Output is correct
7 Correct 39 ms 848 KB Output is correct
8 Correct 40 ms 916 KB Output is correct
9 Correct 54 ms 900 KB Output is correct
10 Correct 40 ms 892 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 2 ms 508 KB Output is correct
15 Correct 2 ms 340 KB Output is correct
16 Correct 2 ms 448 KB Output is correct
17 Incorrect 3 ms 340 KB Output isn't correct
18 Halted 0 ms 0 KB -