QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#260076#5073. Elden RingicreiysCompile Error//C++233.5kb2023-11-21 19:43:072023-11-21 19:43:08

Judging History

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

  • [2023-11-21 19:43:08]
  • 评测
  • [2023-11-21 19:43:07]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
const int maxn = 2e5+10;

int n,m,A,B;
    bool vis[maxn]={0,1};
    bool kill[maxn];
    int cnt=0;//当前能刷几只怪
    int node[maxn]={0};//第i只怪的天数
    int dis[maxn]={0};
    vector<int>arr[maxn];//待访问数组
    vector<int>edges[maxn];

void solve()
{
    
    
    cin>>n>>m>>A>>B;

    for(int i=0;i<=n+5;i++){
        vis[i]=0;
        kill[i]=0;
        node[i]=0;
        dis[i]=0;
        edges[i].clear();
        arr[i].clear();
    }
    vis[1]=1;


    for(int i=1;i<=m;i++){
        int tem1,tem2;
        cin>>tem1>>tem2;
        edges[tem1].push_back(tem2);
        edges[tem2].push_back(tem1);
    }

    if(A>B){
        int ori,tem;
        cin>>ori;
        for(int i=2;i<=n;i++){
            cin>>tem;
            node[i]=max(1,1+(tem+B-ori+(A-B-1))/(A-B));
        }

        arr[1].push_back(1);
        int now=1;
        for(;now<=n;now++){
            if(arr[now].size()==0){
                if(cnt>now)continue;
                else{
                    cout<<-1<<endl;
                    return;
                }

            }
            for(auto it :arr[now]){
                if(kill[it])continue;
                kill[it]=1;
                cnt++;
                if(n==it){
                    cout<<now<<endl;
                    return;
                }
                for(auto e_it:edges[it]){
                    if(vis[e_it])continue;
                    vis[e_it]=1;
                    if(node[e_it]>=n+1)arr[n+1].push_back(e_it);
                    else if(node[e_it]<=now)arr[now+1].push_back(e_it);
                    else arr[node[e_it]].push_back(e_it);
                }
                

            }
        }
        

    }
    else if(A<B){

        int ori,tem;
        cin>>ori;
        for(int i=2;i<=n;i++){
            cin>>tem;
            if(ori<tem)node[i]=0;
            else node[i]=min(maxn,((ori-tem-B)/(B-A))+1);
        }

        queue<int> qu;
        qu.push(1);
        vis[1]=1;
        while(!qu.empty()){
            int tem=qu.front();
            qu.pop();
            for(auto e_id: edges[tem]){
                if(vis[e_id])continue;
                vis[e_id]=1;
                if(node[e_id]>dis[tem]){
                    dis[e_id]=dis[tem]+1;
                    qu.push(e_id);
                }
            }

        }
        if(dis[n])cout<<dis[n]<<endl;
        else cout<<-1<<endl;
        return;
        
    }
    else{
        //A=B
        int ori,tem;
        cin>>ori;
        for(int i=2;i<=n;i++){
            cin>>tem;
            node[i]=ori>=(tem+B);
        }

        queue<int> qu;
        qu.push(1);
        vis[1]=1;
        while(!qu.empty()){
            int tem=qu.front();
            qu.pop();
            for(auto e_id: edges[tem]){
                if(vis[e_id])continue;
                vis[e_id]=1;
                if(node[e_id]){
                    dis[e_id]=dis[tem]+1;
                    qu.push(e_id);
                }
            }

        }
        if(dis[n])cout<<dis[n]<<endl;
        else cout<<-1<<endl;
        return;
    }


    
    return;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

/*
2
5 4 5 8
1 2
1 3
1 4
4 5
15 1 1 1 1
5 4 10 5
1 2
1 3
1 4
4 5
10 4 4 4 19


2
4

1
2 1 5 8
1 2 
1 2

*/

Details

answer.code:9:19: error: ‘bool kill [200010]’ redeclared as different kind of entity
    9 |     bool kill[maxn];
      |                   ^
In file included from /usr/include/c++/11/csignal:42,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:43,
                 from answer.code:1:
/usr/include/signal.h:112:12: note: previous declaration ‘int kill(__pid_t, int)’
  112 | extern int kill (__pid_t __pid, int __sig) __THROW;
      |            ^~~~
answer.code: In function ‘void solve()’:
answer.code:24:15: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   24 |         kill[i]=0;
      |               ^
answer.code:24:16: error: assignment of read-only location ‘*(kill + ((sizetype)i))’
   24 |         kill[i]=0;
      |         ~~~~~~~^~
answer.code:60:27: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   60 |                 if(kill[it])continue;
      |                           ^
answer.code:61:24: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   61 |                 kill[it]=1;
      |                        ^
answer.code:61:25: error: assignment of read-only location ‘*(kill + ((sizetype)it))’
   61 |                 kill[it]=1;
      |                 ~~~~~~~~^~