QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#789032#7588. Monster Hunterkonata2828Compile Error//C++981.7kb2024-11-27 19:06:442024-11-27 19:06:44

Judging History

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

  • [2024-11-27 19:06:44]
  • 评测
  • [2024-11-27 19:06:44]
  • 提交

answer

// Hydro submission #6746fd429592d6097b86cb9f@1732705603053
#include <bits/stdc++.h>
using namespace std;
#define clo 1000.*clock()/CLOCKS_PER_SEC
#ifndef xxzx
#define endl '\n'
#endif
using ll=long long;
using PII=pair<int,int>;
const int N=1e5+10;
bool memory1;
int n;
ll a[N],b[N];
vector<int> eg[N];
struct cmp {
    bool operator()(const int &x,const int &y) {
        if((a[x]<=b[x])!=(a[y]<=b[y])) return (a[x]>b[x]);
        if(a[x]<=b[x]) return a[x]>a[y];
        return b[x]<b[y];
    }
};
int fa[N];
void dfs(int x) {
    for(auto y:eg[x]) if(y!=fa[x]) fa[y]=x,dfs(y);
}
int f[N];
int find(int x) { return (x==f[x])? x:f[x]=find(f[x]); }
bool memory2;
int main() {
    freopen("tree.in","r",stdin);
    freopen("tree.out","w",stdout);
    ios::sync_with_stdio(false), cin.tie(nullptr);

    cin>>n;
    priority_queue<int,vector<int>,cmp> q;
    for(int i=2;i<=n;i++) cin>>a[i]>>b[i];
    for(int i=1,x,y;i<n;i++) cin>>x>>y,eg[x].push_back(y),eg[y].push_back(x);
    dfs(1);
    for(int i=1;i<=n;i++) f[i]=i;
    for(int i=2;i<=n;i++) q.push(i);
    ll v1=0,v2=0;
    while(q.size()) {
        int x=q.top(); q.pop();
        int y=find(fa[x]);
        // cerr<<x<<" "<<y<<endl;
        if(y!=1) {
            ll w=-a[x]+b[x]-a[y]+b[y];
            a[y]=max(a[y],a[x]-(-a[y]+b[y]));
            b[y]=w+a[y];
            // cerr<<"Upd "<<y<<" "<<a[y]<<" "<<b[y]<<endl;
        }
        else {
            v2=max(v2,a[x]-v1);
            v1=v1-a[x]+b[x];
        }
        f[x]=y;
    }
    cout<<v2<<endl;

    #ifdef xxzx
    cerr<<"Time: "<<clo<<"MS"<<endl;
    cerr<<"Memory: "<<abs(&memory1-&memory2)/1024./1024.<<"MB"<<endl;
    #endif
    return 0;
}

详细

answer.code:8:7: error: expected nested-name-specifier before ‘ll’
    8 | using ll=long long;
      |       ^~
answer.code:9:7: error: expected nested-name-specifier before ‘PII’
    9 | using PII=pair<int,int>;
      |       ^~~
answer.code:13:1: error: ‘ll’ does not name a type
   13 | ll a[N],b[N];
      | ^~
answer.code: In member function ‘bool cmp::operator()(const int&, const int&)’:
answer.code:17:13: error: ‘a’ was not declared in this scope
   17 |         if((a[x]<=b[x])!=(a[y]<=b[y])) return (a[x]>b[x]);
      |             ^
answer.code:17:19: error: ‘b’ was not declared in this scope
   17 |         if((a[x]<=b[x])!=(a[y]<=b[y])) return (a[x]>b[x]);
      |                   ^
answer.code:18:12: error: ‘a’ was not declared in this scope
   18 |         if(a[x]<=b[x]) return a[x]>a[y];
      |            ^
answer.code:18:18: error: ‘b’ was not declared in this scope
   18 |         if(a[x]<=b[x]) return a[x]>a[y];
      |                  ^
answer.code:19:16: error: ‘b’ was not declared in this scope
   19 |         return b[x]<b[y];
      |                ^
answer.code: In function ‘void dfs(int)’:
answer.code:24:14: error: ‘y’ does not name a type
   24 |     for(auto y:eg[x]) if(y!=fa[x]) fa[y]=x,dfs(y);
      |              ^
answer.code:24:51: error: expected ‘;’ before ‘}’ token
   24 |     for(auto y:eg[x]) if(y!=fa[x]) fa[y]=x,dfs(y);
      |                                                   ^
      |                                                   ;
   25 | }
      | ~                                                  
answer.code:25:1: error: expected primary-expression before ‘}’ token
   25 | }
      | ^
answer.code:24:51: error: expected ‘;’ before ‘}’ token
   24 |     for(auto y:eg[x]) if(y!=fa[x]) fa[y]=x,dfs(y);
      |                                                   ^
      |                                                   ;
   25 | }
      | ~                                                  
answer.code:25:1: error: expected primary-expression before ‘}’ token
   25 | }
      | ^
answer.code:24:51: error: expected ‘)’ before ‘}’ token
   24 |     for(auto y:eg[x]) if(y!=fa[x]) fa[y]=x,dfs(y);
      |        ~                                          ^
      |                                                   )
   25 | }
      | ~                                                  
answer.code:25:1: error: expected primary-expression before ‘}’ token
   25 | }
      | ^
answer.code: In function ‘int main()’:
answer.code:32:42: error: ‘nullptr’ was not declared in this scope
   32 |     ios::sync_with_stdio(false), cin.tie(nullptr);
      |                                          ^~~~~~~
answer.code:36:32: error: ‘a’ was not declared in this scope
   36 |     for(int i=2;i<=n;i++) cin>>a[i]>>b[i];
      |                                ^
answer.code:36:38: error: ‘b’ was not declared in this scope
   36 |     for(int i=2;i<=n;i++) cin>>a[i]>>b[i];
      |                                      ^
answer.code:41:5: error: ‘ll’ was not declared in this scope
   41 |     ll v1=0,v2=0;
      |     ^~
answer.code:47:15: error: expected ‘;’ before ‘w’
   47 |             ll w=-a[x]+b[x]-a[y]+b[y];
      |               ^~
      |               ;
answer.code:48:13: error: ‘a’ was not declared in this scope
   48 |             a[y]=max(a[y],a[x]-(-a[y]+b[y]));
      |             ^
answer.code:48:39: error: ‘b’ was not declared in this scope
   48 |             a[y]=max(a[y],a[x]-(-a[y]+b[y]));
      |                                       ^
answer.code:49:18: error: ‘w’ was not declared in this scope
   49 |             b[y]=w+a[y];
      |                  ^
answer.code:53:13: error: ‘v2’ was not declared in this scope
   53 |             v2=max(v2,a[x]-v1);
      |             ^~
answer.code:53:23: error: ‘a’ was not declared in this scope
   53 |             v2=max(v2,a[x]-v1);
      |                       ^
answer.code:53:28: error: ‘v1’ was not declared in this scope; did you mean ‘y1’?
   53 |             v2=max(v2,a[x]-v1);
      |                            ^~
      |                            y1
answer.code:54:24: error: ‘b’ was not declared in this scope
   54 |             v1=v1-a[x]+b[x];
      |                        ^
answer.code:58:11: error: ‘v2’ was not declared in this scope
   58 |     cout<<v2<<endl;
      |           ^~
answer.code:30:12: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   30 |     freopen("tree.in","r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~
answer.code:31:12: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   31 |     freopen("tree.out","w",stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~