이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int n,M,Q;
set <int> s;
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)
{
    auto vst=distance(s.begin(), s.upper_bound(x));
    int vdr=*s.lower_bound(x);
    cout<<'\n';
    cout<<vst<<' '<<vdr<<'\n';
    if(vst==0)
        vst=*s.end();
    if(vdr==s.size())
        vdr=*s.begin();
    cout<<vst<<' '<<vdr<<'\n';
    return 0;
    int dist1=stanga(x,vst)+stanga(vst,y);
    int dist2=stanga(x,vst)+dreapta(vst,y);
    int dist3=dreapta(x,vdr)+stanga(vdr,y);
    int dist4=dreapta(x,vdr)+dreapta(vdr,y);
    return min(dist1,min(dist2,min(dist3,dist4)));
}
int main()
{
    cin>>n>>M>>Q;
    for(int i=1;i<=M;++i)
    {
        int x;
        cin>>x;
        s.insert(abs(2*n-x));
        s.insert(abs(x));
    }
    for(int i=1;i<=Q;++i)
    {
        int a,b;
        cin>>a>>b;
        cout<<shc(a,b);
    cout<<'\n';
    }
    return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
Main.cpp: In function 'int shc(int, int)':
Main.cpp:27:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::set<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |     if(vdr==s.size())
      |        ~~~^~~~~~~~~~| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... |