Logo Wy Online Judge

WyOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#488#93. 「NOIP2020」排水系统PigsyyCompile Error//C++235.8kb2025-04-25 14:52:512025-04-25 14:52:51

answer

#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
#include<vector>
#include<map>
using namespace std;

struct _int128 {
	unsigned long long low;
	long long high;
	bool sign;
	_int128(unsigned long long a, long long b, bool c = 1):
		low(a), high(b), sign(c) {}
	_int128(unsigned long long a=0): low(a), high(0), sign(1) {}
	_int128 operator= (const _int128 &x) {
		low = x.low, high = x.high, sign = x.sign;
		return (*this);
	}
	bool operator== (const _int128 &y) const {
		auto x = (*this);
		return x.sign == y.sign && x.low == y.low && x.high == y.high;
	}
	bool operator< (const _int128 &y) const {
		auto x = (*this);
		if (x.sign < y.sign) return 1;
		if (x.sign > y.sign) return 0;
		if (x.high < y.high) return 1;
		if (x.high > y.high) return 0;
		if (x.low < y.low) return 1;
		if (x.low > y.low) return 0;
		return 0;
	}
	bool operator<= (const _int128 &y) const {
		auto x = (*this);
		return x < y || x == y;
	}
	bool operator> (const _int128 &y) const {
		auto x = (*this);
		return !(x <= y);
	}
	bool operator>= (const _int128 &y) const {
		auto x = (*this);
		return !(x < y);
	}
	_int128 operator- () {
		auto t = (*this);
		t.sign ^= 1;
		return t;
	}
	_int128 add(_int128 x, _int128 y) {
		auto lo = x.low + y.low;
		auto hi = x.high + y.high;
		hi += lo < x.low;
		return _int128(lo, hi);
	}
	_int128 sub(_int128 x, _int128 y) {
		bool neg = false;
		if (x < y) swap(x, y), neg = true;
		auto lo = x.low - y.low;
		auto hi = x.high - y.high;
		hi -= x.low < y.low;
		return _int128(lo, hi, neg);
	}
	_int128 operator+ (_int128 y) {
		auto x = (*this);
		if (x.sign ^ y.sign) {
			if (x < y) swap(x, y);
			return sub(x, y);
		} else {
			auto t = add(x, y);
			t.sign ^= x.sign;
			return t;
		}
	}
	_int128 operator+= (const _int128 &x) {
		return (*this) = (*this) + x;
	}
	_int128 operator- (_int128 y) const {
		auto x = (*this);
		return x + (-y);
	}
	_int128 operator-= (const _int128 &x) {
		return (*this) = (*this) - x;
	}
	_int128 operator<< (const unsigned long long &y) const {
		auto x = (*this);
		if (y > 128) return _int128(0, 0);
		if (y >= 64) {
			return _int128(0, x.low << (y - 64), x.sign);
		} else {
			_int128 res = x;
			unsigned long long t = x.low >> (64 - y);
			res.high = (res.high << y) + t;
			res.low = res.low << y;
			return res;
		}
	}
	_int128 operator<<= (const unsigned long long &y) {
		return (*this) = (*this) << y;
	}
	_int128 operator>> (const unsigned long long &y) const {
		auto x = (*this);
		if (y > 128) return _int128(0, 0);
		if (y >= 64) {
			return _int128(x.high >> (y - 64), 0, x.sign);
		} else {
			_int128 res = x;
			unsigned long long t = x.high & ((1ll << y) - 1);
			res.low = (res.low >> y) + (t << (64 - y));
			res.high = res.high >> y;
			return res;
		}
	}
	_int128 operator>>= (const unsigned long long &y) {
		return (*this) = (*this) >> y;
	}
	_int128 operator& (_int128 y) {
		auto x = (*this);
		if (!x.sign) x.low = ~x.low, x.high = ~x.high;
		if (!y.sign) y.low = ~y.low, y.high = ~y.high;
		return _int128(x.low & y.low, abs(x.high & y.high), x.sign | y.sign);
	}
	_int128 operator| (_int128 y) {
		auto x = (*this);
		if (!x.sign) x.low = ~x.low, x.high = ~x.high;
		if (!y.sign) y.low = ~y.low, y.high = ~y.high;
		return _int128(x.low | y.low, abs(x.high | y.high), x.sign & y.sign);
	}
	_int128 operator^ (_int128 y) {
		auto x = (*this);
		if (!x.sign) x.low = ~x.low, x.high = ~x.high;
		if (!y.sign) y.low = ~y.low, y.high = ~y.high;
		return _int128(x.low ^ y.low, abs(x.high ^ y.high), !(x.sign ^ y.sign));
	}
	_int128 operator&= (const _int128 &x) {
		return (*this) = (*this) & x;
	}
	_int128 operator|= (const _int128 &x) {
		return (*this) = (*this) | x;
	}
	_int128 operator^= (const _int128 &x) {
		return (*this) = (*this) ^ x;
	}
	_int128 operator* (const _int128 &y) const {
		auto x = (*this);
		long long H = x.high * y.low + x.low * y.high, L = 0;
		unsigned int LH1 = x.low / (1ll << 32), LH2 = y.low / (1ll << 32);
		unsigned int LL1 = x.low, LL2 = y.low;
		H += (long long)LH1 * LH2, L += (long long)LL1 * LL2;
		_int128 res = _int128(L, H, x.sign xor y.sign);
		res += _int128((unsigned long long)LL1 * LH2) << 32;
		res += _int128((unsigned long long)LH1 * LL2) << 32;
		return res;
	}
};
#define ll _int128
inline ll read(){
	ll x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int n,m,in[100001],out[100001],book[100001];
ll xx[100001],yy[100001];
ll gcd(ll x,ll y){
	if (!x || !y) return x + y;
	while (x != y) {
		if (x > y) x -= y;
		else y -= x;
	}
	return x;
}
void add(int u,ll x,ll y){
	if(y==0)
		return;
	if(yy[u]==0){
		xx[u]=x;
		yy[u]=y;
		return;
	}
	ll p1=xx[u]*y+yy[u]*x;
	ll p2=yy[u]*y;
	ll p3=gcd(p1,p2);
	xx[u]=p1/p3;
	yy[u]=p2/p3;
	return;
}
vector<int> a[500001];
queue<int> q;
void tp(){
	for(int i=1;i<=n;i++)
		if(!in[i]){
			book[i]=1;
			q.push(i);
			xx[i]=1,yy[i]=1;
		}
	while(!q.empty()){
		int p=q.front();
		q.pop();
		if(out[p])
			continue;
		for(int i=0;i<a[p].size();i++){
			add(a[p][i],xx[p],yy[p]*(1ll*a[p].size()));
			if(book[a[p][i]])
				continue;
			in[a[p][i]]--;
			if(in[a[p][i]]==0){
				book[a[p][i]]=1;
				q.push(a[p][i]);
			}
		}
	}
	return;
}
int main()
{
	//freopen("water.in","r",stdin);
	//freopen("water.out","w",stdout);
	n=read(),m=read();
	for(int i=1;i<=n;i++){
		int d=read();
		if(d==0){
			out[i]=1;
			continue;
		}
		while(d--){
			int v;
			v=read();
			a[i].push_back(v);
			in[v]++;
		}
	}
	tp();
	for(int i=1;i<=n;i++){
		if(out[i]){
			add(i,0,1);
			printf("%lld %lld\n",xx[i],yy[i]);
		}
	}
	return 0;
}

详细

answer.code: In function ‘_int128 gcd(_int128, _int128)’:
answer.code:169:13: error: no match for ‘operator!’ (operand type is ‘_int128’)
  169 |         if (!x || !y) return x + y;
      |             ^~
answer.code:169:13: note: candidate: ‘operator!(bool)’ (built-in)
answer.code:169:13: note:   no known conversion for argument 1 from ‘_int128’ to ‘bool’
answer.code:169:19: error: no match for ‘operator!’ (operand type is ‘_int128’)
  169 |         if (!x || !y) return x + y;
      |          ...