제출 #134566

#제출 시각아이디문제언어결과실행 시간메모리
134566Boxworld팀들 (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[]){ int head=0; sort(K,K+M); priority_queue<P,vector<P>,greater<P> >Q; 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.size()<K[i])return 0; for (int j=0;j<K[i];j++) P p=Q.top();Q.pop(); if (p.first<=K[i]&&K[i]<=p.second)continue; else return 0; } while(Q.top().first<=K[i]){ P p=Q.top();Q.pop(); if (K[i]<p.second)Q.push(make_pair(K[i]+1,p.second)); } } return 1; }

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

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