제출 #276229

#제출 시각아이디문제언어결과실행 시간메모리
276229stoyan_malinin팀들 (IOI15_teams)C++14
34 / 100
4058 ms43832 KiB
#include "teams.h"
//#include "grader.cpp"

#include <set>
#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;

struct Event
{
    int type;
    int pos;

    pair <int, int> info;

    Event(){}
    Event(int type, int pos,  pair <int, int> info)
    {
        this->type = type;
        this->pos = pos;

        this->info = info;
    }
};

bool operator <(Event A, Event B)
{
    if(A.pos!=B.pos) return A.pos<B.pos;
    return A.type<B.type;
}

int n;
int *a, *b;

void init(int N, int A[], int B[])
{
    n = N;
    a = A;
    b = B;
}

int can(int M, int K[])
{
    multiset <pair <int, int>> s;
    vector <Event> v;

    for(int i = 0;i<n;i++)
    {
        v.push_back(Event(0, a[i], {b[i], a[i]}));
        v.push_back(Event(2, b[i], {b[i], a[i]}));
    }
    for(int i = 0;i<M;i++)
    {
        v.push_back(Event(1, K[i], {K[i], K[i]}));
    }

    sort(v.begin(), v.end());
    //for(Event e: v) cout << e.type << " -> " << e.info.first << " " << e.info.second << '\n';

    for(Event e: v)
    {
        if(e.type==0)
        {
            s.insert(e.info);
        }
        else if(e.type==1)
        {
            if(s.size()<e.info.first) return 0;
            for(int rem = 0;rem<e.info.first;rem++) s.erase(s.find(*s.begin()));
        }
        else if(e.type==2)
        {
            if(s.find(e.info)!=s.end()) s.erase(s.find(e.info));
        }

        //cout << e.type << " -> " << e.info.first << " " << e.info.second << " || " << s.size() << '\n';
    }

    return 1;
}
/*
4
1 2
2 3
2 3
2 4
2
2
1 3
2
1 1
*/

컴파일 시 표준 에러 (stderr) 메시지

teams.cpp: In constructor 'Event::Event(int, int, std::pair<int, int>)':
teams.cpp:20:5: warning: declaration of 'info' shadows a member of 'Event' [-Wshadow]
   20 |     {
      |     ^
teams.cpp:16:21: note: shadowed declaration is here
   16 |     pair <int, int> info;
      |                     ^~~~
teams.cpp:20:5: warning: declaration of 'pos' shadows a member of 'Event' [-Wshadow]
   20 |     {
      |     ^
teams.cpp:14:9: note: shadowed declaration is here
   14 |     int pos;
      |         ^~~
teams.cpp:20:5: warning: declaration of 'type' shadows a member of 'Event' [-Wshadow]
   20 |     {
      |     ^
teams.cpp:13:9: note: shadowed declaration is here
   13 |     int type;
      |         ^~~~
teams.cpp: In constructor 'Event::Event(int, int, std::pair<int, int>)':
teams.cpp:25:5: warning: declaration of 'info' shadows a member of 'Event' [-Wshadow]
   25 |     }
      |     ^
teams.cpp:16:21: note: shadowed declaration is here
   16 |     pair <int, int> info;
      |                     ^~~~
teams.cpp:25:5: warning: declaration of 'pos' shadows a member of 'Event' [-Wshadow]
   25 |     }
      |     ^
teams.cpp:14:9: note: shadowed declaration is here
   14 |     int pos;
      |         ^~~
teams.cpp:25:5: warning: declaration of 'type' shadows a member of 'Event' [-Wshadow]
   25 |     }
      |     ^
teams.cpp:13:9: note: shadowed declaration is here
   13 |     int type;
      |         ^~~~
teams.cpp: In constructor 'Event::Event(int, int, std::pair<int, int>)':
teams.cpp:25:5: warning: declaration of 'info' shadows a member of 'Event' [-Wshadow]
   25 |     }
      |     ^
teams.cpp:16:21: note: shadowed declaration is here
   16 |     pair <int, int> info;
      |                     ^~~~
teams.cpp:25:5: warning: declaration of 'pos' shadows a member of 'Event' [-Wshadow]
   25 |     }
      |     ^
teams.cpp:14:9: note: shadowed declaration is here
   14 |     int pos;
      |         ^~~
teams.cpp:25:5: warning: declaration of 'type' shadows a member of 'Event' [-Wshadow]
   25 |     }
      |     ^
teams.cpp:13:9: note: shadowed declaration is here
   13 |     int type;
      |         ^~~~
teams.cpp: In function 'int can(int, int*)':
teams.cpp:70:24: warning: comparison of integer expressions of different signedness: 'std::multiset<std::pair<int, int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   70 |             if(s.size()<e.info.first) return 0;
      |                ~~~~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...