QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#579594#9319. Bull FarmlmeowdnCompile Error//C++143.9kb2024-09-21 15:46:002024-09-21 15:46:00

Judging History

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

  • [2024-09-21 15:46:00]
  • 评测
  • [2024-09-21 15:46:00]
  • 提交

answer

//Shirasu Azusa 2024.09
#include<bits/stdc++.h>
#define fi first
#define se second
#define eb emplace_back
#define mp make_pair
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef __int128 i128;
template<typename T,typename U>
T ceil(T x, U y) {return (x>0?(x+y-1)/y:x/y);}
template<typename T,typename U>
T floor(T x, U y) {return (x>0?x/y:(x-y+1)/y);}
template<class T,class S>
bool chmax(T &a,const S b) {return (a<b?a=b,1:0);}
template<class T,class S>
bool chmin(T &a,const S b) {return (a>b?a=b,1:0);}
int popcnt(int x) {return __builtin_popcount(x);}
int popcnt(ll x)  {return __builtin_popcountll(x);}
int topbit(int x) {return (x==0?-1:31-__builtin_clz(x));}
int topbit(ll x)  {return (x==0?-1:63-__builtin_clzll(x));}
int lowbit(int x) {return (x==0?-1:__builtin_ctz(x));}
int lowbit(ll x)  {return (x==0?-1:__builtin_ctzll(x));}

#define int long long
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vp;
typedef tuple<int,int,int> tiii;
int read() {
  int x=0,w=1; char c=getchar(); 
  while(!isdigit(c)) {if(c=='-') w=-1; c=getchar();}
  while(isdigit(c)) {x=x*10+(c-'0'); c=getchar();} 
  return x*w;    
}

const int N=2005,M=1e6+5;
int n,m,q,f[N][N],id[N],a[M],b[M],t[N][N],ans[N];
bitset<N> fr[N],to[N];
vi qq[N];

int getint(char a,char b) {
  return (a-48)*50+(b-48);
}
int find(int i) {
  return i==id[i]?i:id[i]=find(id[i]); 

signed main() {
  int T=read();
  while(T--) {
    n=read(), m=read(), q=read();
    rep(i,1,n) rep(j,1,n) f[i][j]=m+1;
    rep(i,1,n) fr[i].reset(), to[i].reset();
    rep(i,1,n) id[i]=i, fr[i][i]=to[i][i]=1;
    rep(i,1,n) f[i][i]=0;
    rep(i,1,m) {
      static char st[N*2];
      scanf("%s",st);
      rep(j,1,n) {
        int x=j*2-2, y=j*2-1;
        t[i][j]=getint(st[x],st[y]);
      }
    }
    rep(i,0,m) qq[i].clear();
    rep(i,1,q) {
      static char st[10];
      scanf("%s",st);
      a[i]=getint(st[0],st[1]), b[i]=getint(st[2],st[3]);
      int c=getint(st[4],st[5]); qq[c].eb(i);
    }
    for(int x:qq[0]) ans[x]=(a[x]==b[x]);  

    rep(i,1,m) {
      static int vs[N];
      rep(i,1,n) vs[i]=0;
      int xc=0,y=0;
      rep(j,1,n) vs[t[i][j]]++;
      rep(i,1,n) if(vs[i]!=1) {
        if(vs[i]==0) {
          if(y) {y=-1; break;}
          else y=i;
        } else xc=i;
      }
      if(y==0) {
        rep(j,1,n) {
          int u=j, v=t[i][j];
          if(find(u)!=find(v)) {
            for(int x=fr[u]._Find_first();1<=x&&x<=n;x=fr[u]._Find_next(x)) {
              int y=find(x);
              to[y]|=to[v];
            }
            for(int x=to[v]._Find_first();1<=x&&x<=n;x=to[v]._Find_next(x)) {
              int y=find(x);
              fr[y]|=fr[u];
            }
            swap(u,v);
            for(int x=fr[u]._Find_first();1<=x&&x<=n;x=fr[u]._Find_next(x)) {
              int y=find(x);
              to[y]|=to[v];
            }
            for(int x=to[v]._Find_first();1<=x&&x<=n;x=to[v]._Find_next(x)) {
              int y=find(x);
              fr[y]|=fr[u];
            }
            swap(u,v);
            id[u]=v;
          }
        }
      } else if(y>0) {
        rep(j,1,n) if(t[i][j]==xc) {
          int u=j, v=y;
          u=find(u), v=find(v);
          for(int x=fr[u]._Find_first();1<=x&&x<=n;x=fr[u]._Find_next(x)) {
            int y=find(x);
            to[y]|=to[v];
          }
          for(int x=to[v]._Find_first();1<=x&&x<=n;x=to[v]._Find_next(x)) {
            int y=find(x);
            fr[y]|=fr[u];
          }
        }
      }
      for(int x:qq[i]) {
        int u=a[x], v=b[x];
        u=find(u), v=find(v);
        //assert(to[u][v]==fr[v][u]);
        if(to[u][v]|fr[v][u]) ans[x]=1;
        else ans[x]=0;
      }
    }
    rep(i,1,q) putchar('0'+ans[i]); puts("");
  }
  return 0;
}

详细

answer.code: In function ‘long long int find(long long int)’:
answer.code:52:12: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   52 | signed main() {
      |            ^~
answer.code:52:12: note: remove parentheses to default-initialize a variable
   52 | signed main() {
      |            ^~
      |            --
answer.code:52:12: note: or replace parentheses with braces to value-initialize a variable
answer.code:52:15: error: a function-definition is not allowed here before ‘{’ token
   52 | signed main() {
      |               ^
answer.code:138:2: error: expected ‘}’ at end of input
  138 | }
      |  ^
answer.code:49:17: note: to match this ‘{’
   49 | int find(int i) {
      |                 ^