QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#689314#9530. A Game On TreeSwd146296#Compile Error//C++141.6kb2024-10-30 16:21:382024-10-30 16:21:38

Judging History

This is the latest submission verdict.

  • [2024-10-30 16:21:38]
  • Judged
  • [2024-10-30 16:21:38]
  • Submitted

answer

v#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#define int long long
using namespace std;
typedef pair<int,int> PII;
const int MX=100020;
const int inf=1e18;


int N, M, T;
int ar[MX], now[MX];
int read()
{
    int r=0, f=1; char ch=getchar();
    while(ch<'0'||ch>'9') {if(ch=='-') f=-1; ch=getchar();}
    while(ch>='0'&&ch<='9') {r=r*10+ch-'0'; ch=getchar();}
    return r*f;
}
struct node
{
    int x, t, c;
    bool operator < (const node &a)const {return x<a.x;}
}pos[MX];
priority_queue<PII> q;
signed main()
{
    // freopen("testdata.in","r",stdin);
    T=read();
    while(T--)
    {
        N=read(); M=read();
        int ans=0;
        for(int i=1;i<=N;i++) ar[i]=read(), ans+=ar[i];
        for(int i=1;i<=N;i++) now[i]=0;
        while(!q.empty()) q.pop();
        for(int i=1;i<=M;i++)
        {
            pos[i].x=read();
            pos[i].t=read();
            pos[i].c=min(ar[pos[i].t],pos[i].x-now[pos[i].t]);
            int l=pos[i].x-pos[i].c, r=pos[i].x; //[l,r] inclusive
            while(!q.empty())
            {
                auto [lq,rq]=q.top();
                if(rq<=l) break;
                else if(lq<l&&rq>l) {pos[i].c-=rq-l; l=lq; q.pop();}
                else if(lq>=l) {pos[i].c-=(rq-lq); q.pop();} 
            }
            q.push({l,r});
            now[pos[i].t]=pos[i].x;
        }
        sort(pos+1,pos+1+M);
        for(int i=1;i<=M;i++)
        {
            if(ans>pos[i].x) ans+=pos[i].c;
        }
        cout << ans << '\n';
    }
    return (0-0);
}

詳細信息

answer.code:1:2: error: stray ‘#’ in program
    1 | v#include<iostream>
      |  ^
answer.code:1:1: error: ‘v’ does not name a type
    1 | v#include<iostream>
      | ^
In file included from /usr/include/c++/13/bits/stl_algobase.h:62,
                 from /usr/include/c++/13/algorithm:60,
                 from answer.code:3:
/usr/include/c++/13/ext/type_traits.h:164:35: error: ‘constexpr const bool __gnu_cxx::__is_null_pointer’ redeclared as different kind of entity
  164 |   __is_null_pointer(std::nullptr_t)
      |                                   ^
/usr/include/c++/13/ext/type_traits.h:159:5: note: previous declaration ‘template<class _Type> constexpr bool __gnu_cxx::__is_null_pointer(_Type)’
  159 |     __is_null_pointer(_Type)
      |     ^~~~~~~~~~~~~~~~~
/usr/include/c++/13/ext/type_traits.h:164:26: error: ‘nullptr_t’ is not a member of ‘std’
  164 |   __is_null_pointer(std::nullptr_t)
      |                          ^~~~~~~~~
In file included from /usr/include/c++/13/bits/stl_pair.h:60,
                 from /usr/include/c++/13/bits/stl_algobase.h:64:
/usr/include/c++/13/type_traits:510:31: error: ‘std::size_t’ has not been declared
  510 |   template<typename _Tp, std::size_t _Size>
      |                               ^~~~~~
/usr/include/c++/13/type_traits:511:25: error: ‘_Size’ was not declared in this scope
  511 |     struct is_array<_Tp[_Size]>
      |                         ^~~~~
/usr/include/c++/13/type_traits:511:31: error: template argument 1 is invalid
  511 |     struct is_array<_Tp[_Size]>
      |                               ^
/usr/include/c++/13/type_traits:617:33: error: ‘nullptr_t’ is not a member of ‘std’
  617 |     struct is_null_pointer<std::nullptr_t>
      |                                 ^~~~~~~~~
/usr/include/c++/13/type_traits:617:33: error: ‘nullptr_t’ is not a member of ‘std’
/usr/include/c++/13/type_traits:617:42: error: template argument 1 is invalid
  617 |     struct is_null_pointer<std::nullptr_t>
      |                                          ^
/usr/include/c++/13/type_traits:621:48: error: template argument 1 is invalid
  621 |     struct is_null_pointer<const std::nullptr_t>
      |                                                ^
/usr/include/c++/13/type_traits:625:51: error: template argument 1 is invalid
  625 |     struct is_null_pointer<volatile std::nullptr_t>
      |                                                   ^
/usr/include/c++/13/type_traits:629:57: error: template argument 1 is invalid
  629 |     struct is_null_pointer<const volatile std::nullptr_t>
      |                                                         ^
/usr/include/c++/13/type_traits:1348:37: error: ‘size_t’ is not a member of ‘std’; did you mean ‘size_t’?
 1348 |     : public integral_constant<std::size_t, alignof(_Tp)>
      |                                     ^~~~~~
In file included from /usr/include/stdio.h:33,
                 from /usr/include/c++/13/cstdio:42,
                 from answer.code:2:
/usr/lib/gcc/x86_64-linux-gnu/13/include/stddef.h:214:23: note: ‘size_t’ declared here
  214 | typedef __SIZE_TYPE__ size_t;
      |                       ^~~~~~
/usr/include/c++/13/type_traits:1348:37: error: ‘size_t’ is not a member of ‘std’; did you mean ‘size_t’?
 1348 |     : public integral_constant<std::size_t, alignof(_Tp)>
      |                                     ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/13/include/stddef.h:214:23: note: ‘size_t’ declared here
  214 | typedef __SIZE_TYPE__ size_t;
      |                       ^~~~~~
/usr/include/c++/13/type_traits:1348:57: error: template argument 1 is invalid
 1348 |     : public integral_constant<std::size_t, alignof(_Tp)>
      |                                                         ^
/usr/include/c++/13/type_traits:1348:57: note: invalid template non-type parameter
/usr/include/c++/13/type_traits:1357:37: error: ‘size_t’ is not a member of ‘std’; did you mean ‘size_t’?
 1357 |     : public integral_constant<std::size_t, 0> { };
      |                                     ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/13/include/stddef.h:214:23: note: ‘size_t’ declared here
  214 | typedef __SIZE_TYPE__ size_t;
      |                       ^~~~~~
/usr/include/c++/13/type_traits:1357:37: error: ‘size_t’ is not a member of ‘std’; did you mean ‘size_t’?
 1357 |     : public integral_constant<std::size_t, 0> { };
      |                                     ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/13/include/stddef.h:214:23: note: ‘size_t’ declared here
  214 | typedef __SIZE_TYPE__ size_t;
      |                       ^~~~~~
/usr/include/c++/13/type_traits:1357:46: error: template argument 1 is invalid
 1357 |     : public integral_constant<std::size_t, 0> { };
      |                                              ^
/usr/include/c++/13/type_traits:1357:46: note: invalid template non-type parameter
/usr/include/c++/13/type_traits:1359:31: error: ‘std::size_t’ has not been declared
 1359 |   template<typename _Tp, std::size_t _Si...