제출 #134569

#제출 시각아이디문제언어결과실행 시간메모리
134569Boxworld팀들 (IOI15_teams)C++14
컴파일 에러
0 ms0 KiB
#include "teams.h"
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
struct S{int l,r;}a[100100];
bool cmp(S x,S y){return x.l<y.l?1:(x.r<y.r?1:0);}
int n;
void init(int N, int A[], int B[]){
    n=N;
    for (int i=0;i<N;i++){
        a[i].l=A[i];a[i].r=B[i];
    }
//    sort(a,a+N,cmp);
 //   for (int i=0;i<N;i++)printf("L:%d R:%d\n",a[i].l,a[i].r);
}
int can(int M, int K[]){
    priority_queue<P,vector<P>,greater<P> >Q;
    sort(K,K+M);
    for (int i=0;i<n;i++)Q.push(make_pair(a[i].l,a[i].r));
    for (int i=0;i<M;i++){
        if (Q.empty())return 0;
        if (Q.size()<K[i])return 0;
        for (int j=0;j<K[i];j++)
            P x=Q.top();
            Q.pop();
            if (x.first<=K[i]&&K[i]<=x.second)continue;
            else return 0;
        }
        P x=Q.top();Q.pop();
        while(x.first<=K[i]){
            if (K[i]<x.second)Q.push(make_pair(K[i]+1,x.second));
            x=Q.top();Q.pop();
        }
    }
	return 1;
}

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

teams.cpp: In function 'int can(int, int*)':
teams.cpp:22:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if (Q.size()<K[i])return 0;
             ~~~~~~~~^~~~~
teams.cpp:23:9: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
         for (int j=0;j<K[i];j++)
         ^~~
teams.cpp:25:13: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
             Q.pop();
             ^
teams.cpp:24:15: warning: variable 'x' set but not used [-Wunused-but-set-variable]
             P x=Q.top();
               ^
teams.cpp:26:17: error: 'x' was not declared in this scope
             if (x.first<=K[i]&&K[i]<=x.second)continue;
                 ^
teams.cpp:30:26: error: 'i' was not declared in this scope
         while(x.first<=K[i]){
                          ^
teams.cpp: At global scope:
teams.cpp:35:2: error: expected unqualified-id before 'return'
  return 1;
  ^~~~~~
teams.cpp:36:1: error: expected declaration before '}' token
 }
 ^