8.17 模拟赛

预计: \(100+30+0+0\)

实际: \(95+30+0+0\)

时间分配上有问题() 应该先去想写\(T2\)的正解再去写\(T4\)诈骗题的()

T1

显然枚举所有的点 对于每一个点记录一个\(deg[u]\)表示这个点的度数 那么对于\(cnt[i]\)的贡献就是组合数\(C_{deg[u]}^i\) 累加起来即可

最终是因为答案不能取模而挂了一个点

#include <bits/stdc++.h>
using namespace std;
#define mid (l+r>>1)
#define endl '\n'
#define inl inline
#define eb emplace_back
#define ls p<<1
#define rs p<<1|1
#define lson ls,l,mid
#define rson rs,mid+1,r
#define mkp make_pair
#define pii pair<int,int>
#define int long long
const int N = 2e6 + 5;
const int maxm = 2e6;
const int mod = 1e9 + 7;
char buf[1<<24] , *p1 , *p2;
#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<24,stdin),p1==p2)?EOF:*p1++)
//#define getchar() cin.get();
int read()
{
	int x = 0 , f = 1;
	char ch = getchar();
	while ( !isdigit(ch) ) { if ( ch == '-' ) f = -1; ch = getchar(); }
	while ( isdigit(ch) ) { x = ( x << 1 ) + ( x << 3 ) + ( ch ^ 48 ); ch = getchar(); }
	return x * f ;
}

int n , m , ans , dag[N] , cnt[N];
int fac[N] , inv[N] , ifac[N];

void init ()
{
	fac[0] = fac[1] = inv[0] = inv[1] = ifac[0] = ifac[1] = 1;
	for ( int i = 2 ; i <= maxm ; i ++ )
	{
		inv[i] = ( ( mod - mod / i ) * inv[mod%i] % mod + mod ) % mod;
		fac[i] = fac[i-1] * i % mod;
		ifac[i] = ifac[i-1] * inv[i] % mod;
	}
}

int C ( int n , int m ) { if ( n < m ) return 0; return fac[n] * ifac[m] % mod * ifac[n-m] % mod; }

signed main ()
{
	freopen ( "mondstadt.in" , "r" , stdin );
	freopen ( "mondstadt.out" , "w" , stdout );
	ios::sync_with_stdio(false);
	cin.tie(nullptr) , cout.tie(nullptr);
	n = read() , m = read();
	for ( int i = 1 , u , v ; i <= m ; i ++ ) u = read() , v = read() , dag[u] ++ , dag[v] ++; 
	init();
	for ( int i = 1 ; i <= n ; i ++ )
		for ( int k = 2 ; k <= min ( dag[i] , n - 1 ) ; k ++ )
			( cnt[k] += C ( dag[i] , k ) ) %= mod;
	for ( int i = 2 ; i < n ; i ++ ) ans ^= cnt[i];
	cout << ans << endl;
	return 0;
}


T2

一开始想到莫队 但实现的时候假了

正解是树状数组二维数点

先将询问排序 为每一个值维护一个\(pos[u]\) 表示和它配对的点的位置 然后查询的时候查询它配对的点在\(l,r\)区间内的数即可

#include <bits/stdc++.h>
using namespace std;
#define mid (l+r>>1)
#define endl '\n'
#define inl inline
#define eb emplace_back
#define ls p<<1
#define rs p<<1|1
#define lson ls,l,mid
#define rson rs,mid+1,r
#define mkp make_pair
#define pii pair<int,int>
const int N = 2e5 + 5;
char buf[1<<24] , *p1 , *p2;
#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<24,stdin),p1==p2)?EOF:*p1++)
//#define getchar() cin.get();
int read()
{
	int x = 0 , f = 1;
	char ch = getchar();
	while ( !isdigit(ch) ) { if ( ch == '-' ) f = -1; ch = getchar(); }
	while ( isdigit(ch) ) { x = ( x << 1 ) + ( x << 3 ) + ( ch ^ 48 ); ch = getchar(); }
	return x * f ;
}

int n , m , res , a[N] , l , r , vis[N] , block , ans[N] , t[N] , pos[N];

struct que { int l , r , id , pos; } q[N];

struct BIT
{
	inl int lowbit ( int x ) { return x & -x; }
	void upd ( int x ) { for ( ; x <= n ; x += lowbit(x) ) t[x] ++; }
	int query ( int x ) { int res = 0; for ( ; x ; x -= lowbit(x) ) res += t[x]; return res; }
}T;

signed main ()
{
	freopen ( "liyue.in" , "r" , stdin );
	freopen ( "liyue.out" , "w" , stdout );
	ios::sync_with_stdio(false);
	cin.tie(nullptr) , cout.tie(nullptr);
	n = read();
	for ( int i = 1 ; i <= n ; i ++ ) a[i] = read();
	m = read();
	for ( int i = 1 ; i <= m ; i ++ ) q[i].l = read() , q[i].r = read() , q[i].id = i;
	sort ( q + 1 , q + m + 1 , [](const que &a , const que &b) { return a.r < b.r; } );
	l = 1 , r = 0;
	for ( int i = 1 ; i <= m ; i ++ ) 
	{
		while ( r < q[i].r )
		{
			r ++;
			for ( int j = 1 ; j * j - a[r] <= n ; j ++ )
				if ( j * j > a[r] && pos[j*j-a[r]] ) T.upd ( pos[j*j-a[r]] );
			pos[a[r]] = r;
		}
		ans[q[i].id] = T.query ( q[i].r ) - T.query ( q[i].l - 1 );
	}
	for ( int i = 1 ; i <= m ; i ++ ) cout << ans[i] << endl;
	return 0;
}

T3

相当于是 桥必须不断 所以\(ans\)先在这些边中取\(min\)

对于基本环,假设最小的三条边为\(𝑤_1,𝑤_2,𝑤_3\) 那么这个环寿命为min\((𝑤_1+𝑤_2,𝑤_3)\) (相当于是交替用\(1,2\)条边或者是只用第三条边的最小值)(?

代码留坑 不会点双

T4

真没想到不特判\(0\)也有\(60\)分 赛时分讨\(0\)分讨一个半小时

赛后推了半小时柿子写出来了\(60pts\)代码

#include <bits/stdc++.h>
using namespace std;
#define mid (l+r>>1)
#define endl '\n'
#define inl inline
#define eb emplace_back
#define ls p<<1
#define rs p<<1|1
#define lson ls,l,mid
#define rson rs,mid+1,r
#define mkp make_pair
#define pii pair<int,int>
#define int long long
const int N = 2e6 + 5;
const int maxm = 2e6;
const int mod = 1e9 + 7;
const double inf = 4e18;
//char buf[1<<24] , *p1 , *p2;
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<24,stdin),p1==p2)?EOF:*p1++)
#define getchar() cin.get();

int read()
{
	int x = 0 , f = 1;
	char ch = getchar();
	while ( !isdigit(ch) ) { if ( ch == '-' ) f = -1; ch = getchar(); }
	while ( isdigit(ch) ) { x = ( x << 1 ) + ( x << 3 ) + ( ch ^ 48 ); ch = getchar(); }
	return x * f ;
}

int cnt[N] , flag;
int vec[5][4];
double x[4];


signed main ()
{
	freopen ( "sumeru.in" , "r" , stdin );
	freopen ( "sumeru.out" , "w" , stdout );
	ios::sync_with_stdio(false);
	cin.tie(nullptr) , cout.tie(nullptr);
	int T = read();
	while ( T -- )
	{
		double a1 = read() , a2 = read() , a3 = read() , b1 = read() , b2 = read() , b3 = read() , c1 = read() , c2 = read() , c3 = read() , d1 = read() , d2 = read() , d3 = read();
		double z = ( (b3*a2-b2*a3) * (d2*a1-d1*a2) - (d3*a2-d2*a3) * (b2*a1-b1*a2) ) / ( (b3*a2-b2*a3) * (a1*c2-a2*c1) - (b2*a1-b1*a2) * (a2*c3-a3*c2) );
		double y = ( (d3*a2-d2*a3) * (a1*c2-a2*c1) - (d2*a1-d1*a2) * (a2*c3-a3*c2) ) / ( (a1*c2-a2*c1) * (b3*a2-b2*a3) - (b2*a1-b1*a2) * (a2*c3-a3*c2) );
		double x = ( (d1*b3-b1*d3) * (b2*c1-b1*c2) - (d1*b2-b1*d2) * (b3*c1-b1*c3) ) / ( (b2*c1-b1*c2) * (b3*a1-b1*a3) - (b3*c1-b1*c3) * (b2*a1-b1*a2) );
		if ( x > 0 && y > 0 && z > 0 ) cout << "YES" << endl;
		else cout << "NO" << endl;	
	}
	return 0;
}

posted @ 2023-08-17 20:13  Echo_Long  阅读(8)  评论(0编辑  收藏  举报