QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#875440#10043. Mod Graphrotcar07Compile Error//C++141.1kb2025-01-29 19:41:572025-01-29 19:41:57

Judging History

This is the latest submission verdict.

  • [2025-01-29 19:41:57]
  • Judged
  • [2025-01-29 19:41:57]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;
constexpr int N=5e4+5;
int n,q,m,a[N],B,col[N];
vector<int> e[N];bool f=1;
void dfs(int p,int c){
    if(~col[p]){
        if(col[p]!=c) f=0;
        return;
    }col[p]=c;
    for(int x:e[p]) dfs(x,c^1);
}
int main(){
    cin>>n>>m>>q;
    for(int i=1;i<=n;i++)cin>>a[i];
    for(int i=1,x;i<=n;i++)cin>>x,B=gcd(B,x),col[i]=-1;
    for(int i=1,u,v;i<=m;i++) cin>>u>>v,e[u].emplace_back(v),e[v].emplace_back(u);
    for(int i=1;i<=n&&f;i++) if(!~col[i]) dfs(i,0);
    int w=0;
    if(f)
    for(int i=1;i<=n;i++){
        if(col[i])(w+=a[i])%=B;
        else (w-=a[i])%=B;
    }
    while(q--){
        int op,x,y;cin>>op>>x;
        if(op==1){
            bool sb=1;
            if(n==1) sb=(a[1]+1==B);
            else if(f){
                int ww=(w+B+col[x])%B;
                sb=(ww==0||ww==1); 
            }
            puts(sb?"YES":"NO");
        }
        else{
            cin>>y;
            if(col[x]) (w+=y-a[x])%=B;
            else (w-=y-a[x])%=B;
            a[x]=y;
        }
    }
}

详细

answer.code: In function ‘int main()’:
answer.code:16:37: error: ‘gcd’ was not declared in this scope
   16 |     for(int i=1,x;i<=n;i++)cin>>x,B=gcd(B,x),col[i]=-1;
      |                                     ^~~