結果

問題 No.382 シャイな人たち (2)
ユーザー LayCurseLayCurse
提出日時 2015-12-06 01:07:02
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 6,210 bytes
コンパイル時間 1,679 ms
コンパイル使用メモリ 172,952 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-14 14:58:31
合計ジャッジ時間 5,381 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘void reader(double*)’:
main.cpp:15:29: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   15 | void reader(double *x){scanf("%lf",x);}
      |                        ~~~~~^~~~~~~~~

ソースコード

diff #

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

#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

#define mygc(c) (c)=getchar_unlocked()
#define mypc(c) putchar_unlocked(c)

#define ll long long
#define ull unsigned ll

void reader(int *x){int k,m=0;*x=0;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){*x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||k>'9')break;*x=(*x)*10+k-'0';}if(m)(*x)=-(*x);}
void reader(ll *x){int k,m=0;*x=0;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){*x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||k>'9')break;*x=(*x)*10+k-'0';}if(m)(*x)=-(*x);}
void reader(double *x){scanf("%lf",x);}
int reader(char c[]){int i,s=0;for(;;){mygc(i);if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF) break;}c[s++]=i;for(;;){mygc(i);if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF) break;c[s++]=i;}c[s]='\0';return s;}
template <class T, class S> void reader(T *x, S *y){reader(x);reader(y);}
template <class T, class S, class U> void reader(T *x, S *y, U *z){reader(x);reader(y);reader(z);}
template <class T, class S, class U, class V> void reader(T *x, S *y, U *z, V *w){reader(x);reader(y);reader(z);reader(w);}

void writer(int x, char c){int s=0,m=0;char f[10];if(x<0)m=1,x=-x;while(x)f[s++]=x%10,x/=10;if(!s)f[s++]=0;if(m)mypc('-');while(s--)mypc(f[s]+'0');mypc(c);}
void writer(ll x, char c){int s=0,m=0;char f[20];if(x<0)m=1,x=-x;while(x)f[s++]=x%10,x/=10;if(!s)f[s++]=0;if(m)mypc('-');while(s--)mypc(f[s]+'0');mypc(c);}
void writer(double x, char c){printf("%.15f",x);mypc(c);}
void writer(const char c[]){int i;for(i=0;c[i]!='\0';i++)mypc(c[i]);}
void writer(const char x[], char c){int i;for(i=0;x[i]!='\0';i++)mypc(x[i]);mypc(c);}
template<class T> void writerLn(T x){writer(x,'\n');}
template<class T, class S> void writerLn(T x, S y){writer(x,' ');writer(y,'\n');}
template<class T, class S, class U> void writerLn(T x, S y, U z){writer(x,' ');writer(y,' ');writer(z,'\n');}
template<class T> void writerArr(T x[], int n){int i;if(!n){mypc('\n');return;}rep(i,n-1)writer(x[i],' ');writer(x[n-1],'\n');}

char memarr[57000000]; void *mem = memarr;
#define MD 1000000007

int maxIndependenceSet(int n, int *es, int **edge, int *res, void *mem, int lim=-1){int i,j,k,f=1,x,y,z=0,U,s,T,*r,*d,*c,*e,*u,*W,**G;pair<int,int>*p;void*E;if(n==0||n<=lim)return 0;if(n==1){res[0]=0;return 1;}r=(int*)mem;d=r+n;c=d+n;e=c+n;u=e+n;p=(pair<int,int>*)(u+n);mem=p+n;rep(i,n)if(es[i]<=1)break;if(i<n){rep(i,n)r[i]=es[i];rep(i,n)e[i]=1;for(;f;){f=0;rep(i,n)if(e[i]&&r[i]<=1){f=1;res[z++]=i;e[i]=0;rep(j,es[i]){k=edge[i][j];if(e[k]){e[k]=0;rep(x,es[k])r[edge[k][x]]--;}}}}U=0;rep(i,n)if(e[i])u[U++]=i;rep(i,n)c[i]=-1;rep(i,U)c[u[i]]=i;W=(int*)mem;G=(int**)(W+U);G[0]=(int*)(G+U);REP(i,1,U)G[i]=G[i-1]+es[u[i-1]];E=G[U-1]+es[u[U-1]];rep(i,U)W[i]=0;rep(i,U)rep(j,es[u[i]]){x=c[edge[u[i]][j]];if(x>=0)G[i][W[i]++]=x;}s=maxIndependenceSet(U,W,G,d,E,max(-1,lim-z));rep(i,s)res[z++]=u[d[i]];return z;}if(lim>=1){rep(i,n)e[i]=es[i];sort(e,e+n);s=0;rep(k,n)s+=es[k];j=0;rep(i,n){j+=e[i];if(2*j>s)break;}if(i<=lim)return z;rep(i,n)if(e[i]>n-i-1)break;if(i<=lim)return z;}rep(i,n)r[i]=-1;x=0;rep(i,n)if(r[i]==-1){s=1;e[0]=i;r[i]=i;x++;while(s){k=e[--s];rep(j,es[k])if(r[edge[k][j]]==-1)r[edge[k][j]]=i,e[s++]=edge[k][j];}}if(x>1){rep(i,n)e[i]=0;k=0;rep(i,n){j=r[i];if(e[j]==0)k++;e[j]++;}rep(i,n)p[i].first=e[i],p[i].second=i;sort(p,p+n);T=n;rep(y,n)if(p[y].first){k=p[y].second;U=0;rep(i,n)if(r[i]==k)u[U++]=i;rep(i,n)c[i]=-1;rep(i,U)c[u[i]]=i;W=(int*)mem;G=(int**)(W+U);G[0]=(int*)(G+U);REP(i,1,U)G[i]=G[i-1]+es[u[i-1]];E=G[U-1]+es[u[U-1]];rep(i,U)W[i]=0;rep(i,U)rep(j,es[u[i]]){x=c[edge[u[i]][j]];if(x>=0)G[i][W[i]++]=x;}T-=U;s=maxIndependenceSet(U,W,G,d,E,max(-1,lim-T-z));rep(i,s)res[z++]=u[d[i]];}return z;}k=0;REP(i,1,n)if(es[k]<es[i])k=i;if(es[k]==2){rep(i,n)e[i]=0;j=k=0;for(;;){e[k]=1;if(e[edge[k][0]]&&e[edge[k][1]])break;if(e[edge[k][0]])k=edge[k][1];else k=edge[k][0];if(j==0)res[z++]=k;j^=1;}return z;}rep(i,n)if(es[i]==2){x=edge[i][0];y=edge[i][1];rep(j,es[x])if(edge[x][j]==y)break;if(j!=es[x]){k=i;rep(i,n)e[i]=1;e[k]=0;rep(i,es[k])e[edge[k][i]]=0;U=0;rep(i,n)if(e[i])u[U++]=i;rep(i,n)c[i]=-1;rep(i,U)c[u[i]]=i;W=(int*)mem;G=(int**)(W+U);G[0]=(int*)(G+U);REP(i,1,U)G[i]=G[i-1]+es[u[i-1]];E=G[U-1]+es[u[U-1]];rep(i,U)W[i]=0;rep(i,U)rep(j,es[u[i]]){x=c[edge[u[i]][j]];if(x>=0)G[i][W[i]++]=x;}s=maxIndependenceSet(U,W,G,d,E,max(lim-1,z-1));if(z<s){z=0;res[z++]=k;rep(i,s)res[z++]=u[d[i]];}return z;}}rep(i,n)e[i]=1;e[k]=0;rep(i,es[k])e[edge[k][i]]=0;U=0;rep(i,n)if(e[i])u[U++]=i;rep(i,n)c[i]=-1;rep(i,U)c[u[i]]=i;W=(int*)mem;G=(int**)(W+U);G[0]=(int*)(G+U);REP(i,1,U)G[i]=G[i-1]+es[u[i-1]];E=G[U-1]+es[u[U-1]];rep(i,U)W[i]=0;rep(i,U)rep(j,es[u[i]]){x=c[edge[u[i]][j]];if(x>=0)G[i][W[i]++]=x;}s=maxIndependenceSet(U,W,G,d,E,max(lim-1,z-1));if(z<s){z=0;res[z++]=k;rep(i,s)res[z++]=u[d[i]];}U=0;rep(i,n)if(i!=k)u[U++]=i;rep(i,n)c[i]=-1;rep(i,U)c[u[i]]=i;W=(int*)mem;G=(int**)(W+U);G[0]=(int*)(G+U);REP(i,1,U)G[i]=G[i-1]+es[u[i-1]];E=G[U-1]+es[u[U-1]];rep(i,U)W[i]=0;rep(i,U)rep(j,es[u[i]]){x=c[edge[u[i]][j]];if(x>=0)G[i][W[i]++]=x;}s=maxIndependenceSet(U,W,G,d,E,max(lim,z));if(z<s){z=0;rep(i,s)res[z++]=u[d[i]];}return z;}
template<class T> void *malloc1d(T **arr, int x, void *mem){(*arr)=(T*)mem;return((*arr)+x);}
template<class T> void *malloc2d(T ***arr, int x, int y, void *mem){int i;(*arr)=(T**)mem;(*arr)[0]=(T*)((*arr)+x);REP(i,1,x)(*arr)[i]=(*arr)[i-1]+y;return((*arr)[x-1]+y);}

ll S;
int get_next(void){
  S = S * 12345 % 1000003;
  return S;
}

int main(){
  int i, j, k;
  int res, arr[200];
  int N, P;
  int *es, **edge, **mat;

  mem = malloc1d(&es, 130, mem);
  mem = malloc2d(&edge, 130, 130, mem);
  mem = malloc2d(&mat, 130, 130, mem);

  reader(&S);
  N = get_next() % 120 + 2;
  P = get_next();

  writerLn(29);
  rep(i,28) arr[i] = i+1;
  writerArr(arr, 28);
  return 0;

  rep(i,N) rep(j,N) mat[i][j] = 0;
  rep(i,N) REP(j,i+1,N){
    k = get_next();
    if(k >= P) mat[i][j] = mat[j][i] = 1;
  }

  rep(i,N) es[i] = 0;
  rep(i,N) rep(j,N) if(mat[i][j]) edge[i][es[i]++] = j;

  res = maxIndependenceSet(N, es, edge, arr, mem);
  if(res==N){
    writerLn(-1);
  } else {
    writerLn(res+1);
    rep(i,res) arr[i]++;
    writerArr(arr,res);
  }

  return 0;
}
0