結果

問題 No.1326 ふたりのDominator
ユーザー tailstails
提出日時 2020-12-23 17:33:45
言語 cLay
(20240104-1)
結果
AC  
実行時間 62 ms / 2,000 ms
コード長 1,237 bytes
コンパイル時間 3,454 ms
コンパイル使用メモリ 186,284 KB
実行使用メモリ 26,724 KB
最終ジャッジ日時 2023-10-24 10:38:49
合計ジャッジ時間 5,768 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
9,352 KB
testcase_01 AC 3 ms
9,352 KB
testcase_02 AC 3 ms
9,364 KB
testcase_03 AC 3 ms
9,372 KB
testcase_04 AC 3 ms
9,376 KB
testcase_05 AC 3 ms
9,348 KB
testcase_06 AC 3 ms
9,352 KB
testcase_07 AC 4 ms
9,480 KB
testcase_08 AC 3 ms
9,468 KB
testcase_09 AC 3 ms
9,476 KB
testcase_10 AC 3 ms
9,484 KB
testcase_11 AC 4 ms
9,484 KB
testcase_12 AC 52 ms
21,624 KB
testcase_13 AC 51 ms
21,620 KB
testcase_14 AC 52 ms
21,624 KB
testcase_15 AC 51 ms
21,640 KB
testcase_16 AC 48 ms
21,692 KB
testcase_17 AC 43 ms
21,440 KB
testcase_18 AC 51 ms
22,940 KB
testcase_19 AC 35 ms
21,416 KB
testcase_20 AC 53 ms
24,588 KB
testcase_21 AC 55 ms
24,620 KB
testcase_22 AC 62 ms
26,724 KB
testcase_23 AC 36 ms
21,772 KB
testcase_24 AC 53 ms
21,620 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:501:8: warning: ignoring return value of ‘ssize_t write(int, const void*, size_t)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
  501 |   write(1,wbuf,q*sizeof*wbuf);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <unistd.h>
#include <sys/mman.h>

#define RD(v) int v=0;{int _c;while(_c=*rp++-48,_c>=0)v=v*10+_c;}

ll wbuf[1d5];

vector<int> nev[5d4];
int ena[1d5][2];
int nvis[5d4];
unionFind uf;

int f1(int ni,int ei){
	if(nvis[ni]){
		return nvis[ni]>0&&++nvis[ni];
	}
	int level=0;
	for(int ej:nev[ni]){
		if(ej!=ei){
			int nj=ni^ena[ej][0]^ena[ej][1];
			nvis[ni]=1;
			int l1=f1(nj,ej)-(nvis[ni]-1);
			level+=l1;
			if(l1){
				uf(ei,ej);
			}
		}
	}
	nvis[ni]=-1;
	return level;
}

int ec[1d5],ecn;
int ge[2][2d5];

{
	char*rp=(char*)mmap(0,1<<28,1,2,0,0);
	RD(n);RD(m);
	uf.walloc(m,1);
	rep(i,m){
		RD(u);RD(v);
		--u;
		--v;
		nev[u].push_back(i);
		nev[v].push_back(i);
		ena[i][0]=u;
		ena[i][1]=v;
	}
	f1(0,-1);
	unordered_set<ll> ens;
	int gen=0;
	rep(i,m){
		int j=uf(i);
		if(!ec[j]){
			ec[j]=~ecn++;
		}
		j=~ec[j];
		rep(k,2){
			if(ens.insert(j<<16|ena[i][k]).second){
				ge[0][gen]=ena[i][k];
				ge[1][gen]=n+j;
				++gen;
			}
		}
	}
	graph g;
	g.setEdge(n+ecn,gen,ge[0],ge[1]);
	HLD h;
	h.init(g);
	ll*wp=wbuf;
	RD(q);
	rep(q){
		RD(x);RD(y);
		--x;--y;
		int z=(x==y?0:h.dist(x,y)/2-1);
		ll d=0x2020202020202020l;
		while(d=d<<8|0x30|z%10,z/=10);
		*wp++=d^42l<<56;
	}
	write(1,wbuf,q*sizeof*wbuf);
	_exit(0);
}
0