답안 #986567

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
986567 2024-05-20T18:57:15 Z activedeltorre Interval Collection (CCO20_day2problem2) C++14
0 / 25
7000 ms 596 KB
#include <iostream>
#include <vector>

using namespace std;
struct ura
{
    int a,b;
};
vector<ura>vec;
int inter(int i,int j)
{
    return max(0,min(vec[i].b,vec[j].b)-max(vec[i].a,vec[j].a));
}
int reun(int i,int j)
{
    return max(vec[i].b,vec[j].b)-min(vec[i].a,vec[j].a);

}
int main()
{
    int n,i,j,k,l,r,z;
    cin>>n;
    char tip;
    for(i=1;i<=n;i++)
    {
        cin>>tip;
        if(tip=='A')
        {
            cin>>l>>r;
            vec.push_back({l,r});
        }
        else if(tip=='R')
        {
            cin>>l>>r;
            for(j=0;j<vec.size();j++)
            {
                if(vec[j].a==l && vec[j].b==r)
                {
                    vec.erase(vec.begin()+j);
                    break;
                }
            }
        }
        int minim=1e9,sol;
        for(j=0;j<vec.size();j++)
        {
            for(z=j;z<vec.size();z++)
            {
                if(inter(z,j)<=minim)
                {
                    minim=inter(z,j);
                    sol=reun(z,j);
                }
            }
        }
        cout<<sol<<'\n';
    }
    return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:35:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<ura>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |             for(j=0;j<vec.size();j++)
      |                     ~^~~~~~~~~~~
Main.cpp:45:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<ura>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |         for(j=0;j<vec.size();j++)
      |                 ~^~~~~~~~~~~
Main.cpp:47:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<ura>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |             for(z=j;z<vec.size();z++)
      |                     ~^~~~~~~~~~~
Main.cpp:21:15: warning: unused variable 'k' [-Wunused-variable]
   21 |     int n,i,j,k,l,r,z;
      |               ^
Main.cpp:56:20: warning: 'sol' may be used uninitialized in this function [-Wmaybe-uninitialized]
   56 |         cout<<sol<<'\n';
      |                    ^~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 20 ms 356 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 20 ms 356 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 20 ms 356 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 7021 ms 596 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 20 ms 356 KB Output isn't correct
2 Halted 0 ms 0 KB -