제출 #412952

#제출 시각아이디문제언어결과실행 시간메모리
412952ScarletS팀들 (IOI15_teams)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;

const int N = 5e5+7;
int n;
array<int,2> a[N];

bool cmp(array<int,2>& x, array<int,2> &y)
{
    return r[x] < r[y];
}

void init(int N, int A, int B)
{
    n=N;
    for (int i=0;i<n;++i)
        a[i]={A[i],B[i]};
    sort(a,a+n);
}

bool can(int m, int k[])
{
    sort(k,k+m);
    int c=0, x=0;
    for (int i=0;i<n&&c<m;++i)
        if (l[i]<=k[c]&&k[c]<=r[i])
            if (++x==k[c])
                x=0,++c;
    return c==m;
}

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

teams.cpp: In function 'bool cmp(std::array<int, 2>&, std::array<int, 2>&)':
teams.cpp:10:12: error: 'r' was not declared in this scope
   10 |     return r[x] < r[y];
      |            ^
teams.cpp: In function 'void init(int, int, int)':
teams.cpp:13:15: warning: declaration of 'N' shadows a global declaration [-Wshadow]
   13 | void init(int N, int A, int B)
      |           ~~~~^
teams.cpp:4:11: note: shadowed declaration is here
    4 | const int N = 5e5+7;
      |           ^
teams.cpp:17:16: error: invalid types 'int[int]' for array subscript
   17 |         a[i]={A[i],B[i]};
      |                ^
teams.cpp:17:21: error: invalid types 'int[int]' for array subscript
   17 |         a[i]={A[i],B[i]};
      |                     ^
teams.cpp:17:24: error: no match for 'operator=' (operand types are 'std::array<int, 2>' and '<brace-enclosed initializer list>')
   17 |         a[i]={A[i],B[i]};
      |                        ^
In file included from /usr/include/c++/10/tuple:39,
                 from /usr/include/c++/10/functional:54,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from teams.cpp:1:
/usr/include/c++/10/array:94:12: note: candidate: 'constexpr std::array<int, 2>& std::array<int, 2>::operator=(const std::array<int, 2>&)'
   94 |     struct array
      |            ^~~~~
/usr/include/c++/10/array:94:12: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const std::array<int, 2>&'
/usr/include/c++/10/array:94:12: note: candidate: 'constexpr std::array<int, 2>& std::array<int, 2>::operator=(std::array<int, 2>&&)'
/usr/include/c++/10/array:94:12: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::array<int, 2>&&'
teams.cpp: In function 'bool can(int, int*)':
teams.cpp:26:13: error: 'l' was not declared in this scope
   26 |         if (l[i]<=k[c]&&k[c]<=r[i])
      |             ^
teams.cpp:26:31: error: 'r' was not declared in this scope
   26 |         if (l[i]<=k[c]&&k[c]<=r[i])
      |                               ^