Submission #167854

# Submission time Handle Problem Language Result Execution time Memory
167854 2019-12-10T15:07:43 Z rzbt Plahte (COCI17_plahte) C++14
0 / 160
4 ms 2168 KB
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define MAXN 80005
typedef long long ll;

using namespace std;

int n,m;
int cale[MAXN],posecen[MAXN];
bool jeste[MAXN];
set<pair<int,int> > iznad;
vector<pair<pair<int,int> ,int> > query;

pair<pair<int,int>, pair<int,int> > prav[MAXN];

vector<int> res[MAXN];
queue<int> red;


int main()
{
    freopen("input.txt","r",stdin);
    scanf("%d %d", &n, &m);
    for(int i=1;i<=n;i++){
        int x1,y1,x2,y2;
        scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
        prav[i]=(mp(mp(x1,y1),mp(x2,y2)));
        query.pb(mp(mp(x1,y1),i));
        query.pb(mp(mp(x2+1,-y2),i));
    }
    for(int i=1;i<=m;i++){
        int x,y,k;
        scanf("%d %d %d", &x, &y, &k);
        query.pb(mp(mp(x,y),-k));
    }
    sort(all(query));
    for(auto q:query){
        //printf("    %d %d   %d\n",q.F.F,q.F.S,q.S);
        if(q.S>0){
            if(q.F.S<0)iznad.erase(mp(-q.F.S,q.S));
            else{
                auto tcale=iznad.upper_bound(mp(prav[q.S].second.second,-1e9+7));
                if(tcale==iznad.end())cale[q.S]=0;
                else cale[q.S]=tcale->S;
                iznad.insert(mp(prav[q.S].second.second,q.S));
                //printf("                     %d\n",prav[q.S].second.second);

            }
        }else{
            auto ti=iznad.lower_bound(mp(q.F.S,-1e9+7));
            if(ti==iznad.end())continue;
            else res[ti->S].pb(-q.S);
        }

    }

    /*for(int i=1;i<=n;i++){
        printf("%d: ",i);
        for(auto x:res[i])printf("%d ",x);
        printf("\n");
    }*/
    for(int i=1;i<=n;i++){
        jeste[cale[i]]=true;
    }
    for(int i=1;i<=n;i++){
        if(!jeste[i])red.push(i);
    }
    while(!red.empty()){
        int t=red.front();
        posecen[t]++;
        red.pop();
        if(posecen[t])continue;
        sort(all(res[t]));
        res[t].erase(unique(all(res[t])),res[t].end());
        if(cale[t]==0)continue;
        for(auto x:res[t])res[cale[t]].pb(x);
        red.push(cale[t]);
    }
    for(int i=1;i<=n;i++)printf("%d\n",res[i].size());


    return 0;
}

Compilation message

plahte.cpp: In function 'int main()':
plahte.cpp:83:53: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::vector<int>::size_type {aka long unsigned int}' [-Wformat=]
     for(int i=1;i<=n;i++)printf("%d\n",res[i].size());
                                        ~~~~~~~~~~~~~^
plahte.cpp:26:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
     freopen("input.txt","r",stdin);
     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
plahte.cpp:27:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d", &n, &m);
     ~~~~~^~~~~~~~~~~~~~~~~
plahte.cpp:30:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
plahte.cpp:37:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d %d", &x, &y, &k);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 2168 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 2168 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 2168 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 2168 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 2168 KB Output isn't correct
2 Halted 0 ms 0 KB -