結果

問題 No.2319 Friends+
ユーザー tailstails
提出日時 2023-05-27 01:34:00
言語 C90
(gcc 11.4.0)
結果
AC  
実行時間 159 ms / 3,000 ms
コード長 1,015 bytes
コンパイル時間 614 ms
コンパイル使用メモリ 27,040 KB
実行使用メモリ 106,776 KB
最終ジャッジ日時 2023-08-26 15:04:51
合計ジャッジ時間 6,699 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
4,948 KB
testcase_01 AC 1 ms
5,008 KB
testcase_02 AC 45 ms
57,116 KB
testcase_03 AC 45 ms
57,036 KB
testcase_04 AC 45 ms
57,132 KB
testcase_05 AC 41 ms
57,088 KB
testcase_06 AC 43 ms
57,028 KB
testcase_07 AC 159 ms
106,776 KB
testcase_08 AC 158 ms
106,624 KB
testcase_09 AC 158 ms
106,712 KB
testcase_10 AC 158 ms
106,768 KB
testcase_11 AC 157 ms
106,624 KB
testcase_12 AC 1 ms
5,572 KB
testcase_13 AC 1 ms
5,572 KB
testcase_14 AC 1 ms
5,492 KB
testcase_15 AC 1 ms
5,584 KB
testcase_16 AC 1 ms
5,700 KB
testcase_17 AC 1 ms
5,608 KB
testcase_18 AC 59 ms
57,424 KB
testcase_19 AC 80 ms
106,028 KB
testcase_20 AC 44 ms
56,060 KB
testcase_21 AC 43 ms
56,164 KB
testcase_22 AC 44 ms
56,216 KB
testcase_23 AC 57 ms
80,984 KB
testcase_24 AC 52 ms
68,572 KB
testcase_25 AC 49 ms
62,232 KB
testcase_26 AC 49 ms
59,208 KB
testcase_27 AC 48 ms
57,616 KB
testcase_28 AC 44 ms
57,124 KB
testcase_29 AC 45 ms
56,356 KB
testcase_30 AC 45 ms
57,212 KB
testcase_31 AC 45 ms
56,140 KB
testcase_32 AC 43 ms
57,072 KB
testcase_33 AC 42 ms
55,988 KB
testcase_34 AC 40 ms
57,088 KB
testcase_35 AC 36 ms
56,120 KB
testcase_36 AC 84 ms
106,764 KB
testcase_37 AC 17 ms
58,872 KB
testcase_38 AC 34 ms
106,084 KB
testcase_39 AC 37 ms
106,124 KB
testcase_40 AC 36 ms
106,168 KB
testcase_41 AC 36 ms
106,252 KB
testcase_42 AC 35 ms
106,296 KB
testcase_43 AC 37 ms
106,260 KB
testcase_44 AC 34 ms
106,288 KB
testcase_45 AC 31 ms
106,104 KB
testcase_46 AC 17 ms
59,300 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:36:7: warning: multi-character character constant [-Wmultichar]
   *wp='\n oN';
       ^~~~~~~
main.c:47:10: warning: multi-character character constant [-Wmultichar]
      *wp='\nseY';
          ^~~~~~~
main.c:54:2: warning: implicit declaration of function ‘write’ [-Wimplicit-function-declaration]
  write(1,wbuf,(wp-wbuf)*sizeof*wbuf);
  ^~~~~
main.c:55:2: warning: implicit declaration of function ‘_exit’ [-Wimplicit-function-declaration]
  _exit(0);
  ^~~~~
main.c:55:2: warning: incompatible implicit declaration of built-in function ‘_exit’

ソースコード

diff #

#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")

#define rd_init() char*rp=({char*mmap();mmap(0l,1l<<25,1,2,0,0ll);})
#define rd_skip() while(*rp++>=48)
#define rd_skip_line() while(*rp++!=10)
#define rd() ({long _v=0,_c;while(_c=*rp++-48,_c>=0)_v=_v*10+_c;_v;})
#define rep(v,e) for(typeof(e) v=0;v<e;++v)
#define rep3(v,s,e) for(typeof(e) v=s;v<e;++v)

typedef unsigned long ulong;

unsigned wbuf[1<<20];
int p[20004];
ulong f[20004][320];
ulong g[20004][320];

int main(){
	rd_init();
	int n=rd();
	int m=rd();
	rep3(i,1,n+1){
		int pi=rd();
		p[i]=pi;
		g[pi][i>>6]|=1ul<<i;
	}
	rep(i,m){
		int a=rd();
		int b=rd();
		f[a][b>>6]|=1ul<<b;
		f[b][a>>6]|=1ul<<a;
	}
	rd_skip();
	unsigned*wp=wbuf;
	while(*rp){
		*wp='\n oN';
		int x=rd();
		int s=p[x];
		int t=p[rd()];
		if(s!=t){
			rep(i,320){
				if(f[x][i]&g[t][i]){
					p[x]=t;
					ulong k=1ul<<x;
					g[s][x>>6]&=~k;
					g[t][x>>6]|=k;
					*wp='\nseY';
					break;
				}
			}
		}
		++wp;
	}
	write(1,wbuf,(wp-wbuf)*sizeof*wbuf);
	_exit(0);
}
0