QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#246266#7678. The GamefAKeZero#Compile Error//C++171.8kb2023-11-10 18:09:362023-11-10 18:09:37

Judging History

你现在查看的是最新测评结果

  • [2023-11-10 18:09:37]
  • 评测
  • [2023-11-10 18:09:36]
  • 提交

answer

// #include <bits/stdc++.h>

template<class _Tp = int>
_Tp read() {
  _Tp ret = 0;
  char ch = getchar(), sgn = 0;
  while (!isdigit(ch)) sgn |= ch == '-', ch = getchar();
  while (isdigit(ch)) ret = ret * 10 + ch - '0', ch = getchar();
  return sgn ? -ret : ret;
}

const int kMaxN = 3e5 + 5;
int n, m;
int a[kMaxN], b[kMaxN];

void clear() {

}

int main() {
  int T = read();
  while (T--) {
    n = read(), m = read();
    for (int i = 1; i <= n; i++)
      a[i] = read();
    for (int i = 1; i <= m; i++)
      b[i] = read();
    int L = n - m;
    std::sort(a + 1, a + n + 1, std::greater<int>());
    std::sort(b + 1, b + m + 1, std::greater<int>());
    long long dis = 0;
    for (int i = 1; i <= m; i++) {
      if (a[i] > b[i]) {
        puts("-1");
        goto end_of_loop;
      }
      dis += b[i] - a[i];
    }
    printf("dis %d?\n", dis);
    if (dis > L) {
      puts("-1");
      goto end_of_loop;
    }
    {
    int redundant = m;
    for (int i = m + 1; i <= n; i++) {
      if (a[i] == b[m])
        redundant++;
      else 
        break;
    }
    printf("redundant %d?\n", redundant);
    if (L > n - redundant + 1) {
      puts("-1");
      goto end_of_loop;
    }
    printf("%d\n", L);
    for (int i = m; i >= 1; i--) {
      puts("HELLO");
      while (a[i] < b[i])
        printf("%d ", a[i]), a[i]++;
    }
    std::multiset<int> S;

    for (int i = redundant + 1; i <= n - dis; i++)
      S.insert(a[i]);
    for (int i = 1; i <= L - dis; i++) {
      int x = *S.begin();
      printf("%d ", x);
      S.erase(S.begin());
      S.insert(x + 1);
    }
    puts("");
    }
    end_of_loop:
      clear();
  }
}

/*
6
5 3
1 2 2 3 3
2 3 4
4 2
1 2 2 4
2 4
5 2
2 3 3 4 4
5 5
6 1
1 1 1 1 1 1
4
4 2
1 1 1 2
2 2
4 1
1 1 1 1
2
*/

Details

answer.code: In function ‘_Tp read()’:
answer.code:6:13: error: there are no arguments to ‘getchar’ that depend on a template parameter, so a declaration of ‘getchar’ must be available [-fpermissive]
    6 |   char ch = getchar(), sgn = 0;
      |             ^~~~~~~
answer.code:6:13: note: (if you use ‘-fpermissive’, G++ will accept your code, but allowing the use of an undeclared name is deprecated)
answer.code:7:11: error: there are no arguments to ‘isdigit’ that depend on a template parameter, so a declaration of ‘isdigit’ must be available [-fpermissive]
    7 |   while (!isdigit(ch)) sgn |= ch == '-', ch = getchar();
      |           ^~~~~~~
answer.code:7:47: error: there are no arguments to ‘getchar’ that depend on a template parameter, so a declaration of ‘getchar’ must be available [-fpermissive]
    7 |   while (!isdigit(ch)) sgn |= ch == '-', ch = getchar();
      |                                               ^~~~~~~
answer.code:8:10: error: there are no arguments to ‘isdigit’ that depend on a template parameter, so a declaration of ‘isdigit’ must be available [-fpermissive]
    8 |   while (isdigit(ch)) ret = ret * 10 + ch - '0', ch = getchar();
      |          ^~~~~~~
answer.code:8:55: error: there are no arguments to ‘getchar’ that depend on a template parameter, so a declaration of ‘getchar’ must be available [-fpermissive]
    8 |   while (isdigit(ch)) ret = ret * 10 + ch - '0', ch = getchar();
      |                                                       ^~~~~~~
answer.code: In function ‘int main()’:
answer.code:29:10: error: ‘sort’ is not a member of ‘std’
   29 |     std::sort(a + 1, a + n + 1, std::greater<int>());
      |          ^~~~
answer.code:29:38: error: ‘greater’ is not a member of ‘std’
   29 |     std::sort(a + 1, a + n + 1, std::greater<int>());
      |                                      ^~~~~~~
answer.code:29:46: error: expected primary-expression before ‘int’
   29 |     std::sort(a + 1, a + n + 1, std::greater<int>());
      |                                              ^~~
answer.code:30:10: error: ‘sort’ is not a member of ‘std’
   30 |     std::sort(b + 1, b + m + 1, std::greater<int>());
      |          ^~~~
answer.code:30:38: error: ‘greater’ is not a member of ‘std’
   30 |     std::sort(b + 1, b + m + 1, std::greater<int>());
      |                                      ^~~~~~~
answer.code:30:46: error: expected primary-expression before ‘int’
   30 |     std::sort(b + 1, b + m + 1, std::greater<int>());
      |                                              ^~~
answer.code:34:9: error: ‘puts’ was not declared in this scope
   34 |         puts("-1");
      |         ^~~~
answer.code:39:5: error: ‘printf’ was not declared in this scope
   39 |     printf("dis %d?\n", dis);
      |     ^~~~~~
answer.code:1:1: note: ‘printf’ is defined in header ‘<cstdio>’; did you forget to ‘#include <cstdio>’?
  +++ |+#include <cstdio>
    1 | // #include <bits/stdc++.h>
answer.code:41:7: error: ‘puts’ was not declared in this scope
   41 |       puts("-1");
      |       ^~~~
answer.code:54:7: error: ‘puts’ was not declared in this scope
   54 |       puts("-1");
      |       ^~~~
answer.code:59:7: error: ‘puts’ was not declared in this scope
   59 |       puts("HELLO");
      |       ^~~~
answer.code:63:10: error: ‘multiset’ is not a member of ‘std’
   63 |     std::multiset<int> S;
      |          ^~~~~~~~
answer.code:1:1: note: ‘std::multiset’ is defined in header ‘<set>’; did you forget to ‘#include <set>’?
  +++ |+#include <set>
    1 | // #include <bits/stdc++.h>
answer.code:63:19: error: expected primary-expression before ‘int’
   63 |     std::multiset<int> S;
      |                   ^~~
answer.code:66:7: error: ‘S’ was not declared in this scope
   66 |       S.insert(a[i]);
      |       ^
answer.code:68:16: error: ‘S’ was not declared in this scope
   68 |       int x = *S.begin();
      |                ^
answer.code:73:5: error: ‘puts’ was not declared in this scope
   73 |     puts("");
      |     ^~~~
answer.code: In instantiation of ‘_Tp read() [with _Tp = int]’:
answer.code:21:15:   required from here
answer.code:6:20: error: ‘getchar’ was not declared in this scope
    6 |   char ch = getchar(), sgn = 0;
      |             ~~~~~~~^~
answer.code:6:20: note: ‘getchar’ is defined in header ‘<cstdio>’; did you forget to ‘#include <cstdio>’?
answer.code:7:18: error: ‘isdigit’ was not declared in this scope
    7 |   while (!isdigit(ch)) sgn |= ch == '-', ch = getchar();
      |           ~~~~~~~^~~~
answer.code:8:17: error: ‘isdigit’ was not declared in this scope
    8 |   while (isdigit(ch)) ret = ret * 10 + ch - '0', ch = getchar();
      |          ~~~~~~~^~~~