首页 > 其他分享 >团队训练记录2024.10.5

团队训练记录2024.10.5

时间:2024-10-05 20:12:22浏览次数:6  
标签:2024.10 include 训练 lo ll cnt long 团队 first

这次double精度上卡了,赛时和学校强队差两题
题目链接:https://codeforces.com/gym/104023/problem

A. Dunai

队友写的,答案在总冠军位人数和位置上冠军加非冠军人数最小取min?

#include<bits/stdc++.h>
#define test(i) cout << #i << " "<< i << " " << endl;
#define endl '\n'

using namespace std;
typedef long long ll;

const int INF=0x3f3f3f3f;
const int N=2e5+5;

ll t,n;

ll cnt[10];
ll cnt1[10];
map<string,ll> mp;//队伍数量
map<string,ll> vis;

void fio(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

signed main()
{
	fio();
	ll m,num;
	cin >> n;
	string str,name;
	for(int i=1; i<=n; i++){
		for(int j=1; j<=5; j++){
			cin >> name;
			vis[name]++;
		}
	}
	cin >> m;
	for(int i=1; i<=m; i++){
		cin >> str >> num;
		if(vis[str]) cnt1[num]++;
		else cnt[num]++;
	}
	ll ans=0;
	ll tmp=1e9+1;
	for(int i=1; i<=5; i++){
		ans+=cnt1[i];
		tmp=min(cnt1[i]+cnt[i],tmp);
	}
	cout << min(ans,tmp) << endl;
	return 0;
}

E. Python Will be Faster than C++

队友写的

#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
using namespace std;
typedef  long long ll;
typedef char ElemType;
void fio()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

ll n, k;
ll a[100];
int main() {
	cin >> n >> k;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	for (int i = 1; i <= n; i++) {
		if (a[i] < k) {
			cout << "Python 3."<<i<<" will be faster than C++"<<endl;
			return 0;
		}
	}
	if (a[n] >= a[n - 1]) {
		cout << "Python will never be faster than C++"<<endl;
	}
	else {
		if (a[n] == k) {
			cout<< "Python 3." << n+1 << " will be faster than C++" << endl;
		}
		else {
			ll ans = (a[n] - k) / (a[n-1] - a[n]) + 1;
			cout << "Python 3." << n+ans << " will be faster than C++" << endl;
		}
	}
}

G. Grade 2

打表得规律

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcd(ll x,ll y)
{
    if(y==0)
    return x;
    else
    return gcd(y,x%y);
}
map<ll,ll>q;
ll a[2550];
ll g[2500000];
int main()
{
ll x,n;
cin>>x>>n;
ll cnt=0;
ll u=x;
//ll j=*lower_bound(a+1,a+1+cnt,x);
for(ll i=1;i<=31;i++)
{
    q[1ll<<i]++;
    cnt++;
    a[cnt]=1ll<<i;
}
ll j=*lower_bound(a+1,a+1+cnt,x);
for(ll i=1;i<=j;i++)
{
    g[i]=0;
}
for(ll i=1;i<=j;i++)
{
    g[i]=g[i-1]+(gcd(((i*x)^x),x)==1);
}
x=j-1;
while(n--)
{
    ll l,r;
    cin>>l>>r;
    if(q[u]>0)
    {
        cout<<0<<endl;
    }
    else
    {
        
            ll u=(l-1)/(x+1);
            ll l1=1+u*(x+1);//左边周期
            ll k=(r-1)/(x+1);
            ll r1=(x+1)+(k)*(x+1);
        // cout<<u<<" "<<l1<<" "<<k<<" "<<r1<<endl;
     //   cout<<g[l-1-l1+1]<<endl;
            cout<<(k-u+1)*(g[x+1])-g[l-1-l1+1]-(g[x+1]-g[((x+1)-(r1-r))])<<endl;
    }
}
}

I. Dragon Bloodline

优先队列+二分+unsigned long long

#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
typedef unsigned long long ll;
ll a[50010];
long long  b[30];
ll c[30];
ll n, k;
bool ck(long long  x)
{
    priority_queue<ll>q;
    for (ll i = 1; i <= n; i++)
    {
        q.push((ll)a[i] * x);
    }
    while (!q.empty())
    {
        int ans = 0;
        ll op = q.top();
        for (ll j = k; j >= 1; j--)
        {
            if (c[j] > 0)
            {
                if (op <= b[j])
                {
                    c[j]--;
                    q.pop();
                }
                else
                {
                    ll u = op / b[j];
                    u = min(u, c[j]);
                    op -= u * b[j];
                    c[j] -= u;
                    q.pop();
                    if (op > 0)
                        q.push(op);
                }
                break;
            }
            else
                ans++;
        }
        if (ans == k)
            break;
    }
    if (q.size() == 0)
    {
        return 1;
    }
    else
        return 0;
}
ll d[25];
int main()
{
    ll t;
    cin >> t;
    while (t--)
    {
        cin >> n >> k;
        for (ll i = 1; i <= n; i++)cin >> a[i];
        for (int i = 1; i <= k; i++)
        {
            cin >> c[i];
            d[i] = c[i];
            b[i] = (1ll << (i - 1));
        }
        long long  l = 1, r = 1e18;
        while (l <= r)
        {
            for (ll i = 1; i <= k; i++)c[i] = d[i];
            long long  mid = (l + r) >> 1;
            if (ck(mid))
                l = mid + 1;
            else
                r = mid - 1;
        }
        cout << r << endl;
    }
}

J. Eat, Sleep, Repeat

双端队列模拟

#include<map>
#include<iostream>
#include<set>
#include<deque>
using namespace std;
typedef long long ll;
void fio()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
ll gcd(ll x, ll y)
{
    if (y == 0)
        return x;
    else
        return gcd(y, x % y);
}
map<ll, ll>q, e;
ll a[255000];
ll g[250000];
set<pair<ll, ll>>f;
int main()
{
    fio();
    ll t;
    cin >> t;
    while (t--)
    {
        f.clear();
        q.clear();
        e.clear();
        ll n, m;
        cin >> n >> m;
        for (ll i = 1; i <= n; i++)
        {
            cin >> a[i];
            q[a[i]]++;
        }
        for (ll i = 1; i <= m; i++)
        {
            ll x, y;
            cin >> x >> y;
            f.insert({ x,y });
            e[x]++;
        }
        for (ll i = 1; i <= n; i++)
        {
            if (e[a[i]] == 0)
            {
                e[a[i]]++;
                f.insert({ a[i],(1e16 + 1) });
            }
        }
        ll u = -1;
        deque<pair<ll, ll>>lo;
        if (e[0] == 0)
        {
            e[0]++;
            f.insert({ 0,1e16 + 1 });
        }
        ll ans = 0;
        ll cnt = -99999999999999;
        for (auto j : f)
        {
            if (q[j.first] > j.second)
            {
                ans = 0;
                break;
            }
            //cout<<j.first<<" "<<j.second<<endl;
            cnt++;
            if (cnt > 0 && j.first != cnt)
            {
                lo.push_back({ 1e16 + 5,cnt });
                cnt = -9999999999999;
            }
            if (lo.empty())
            {
                ll op = j.second - q[j.first];
                q[j.first] = 0;
                if (op > 0)
                {
                    lo.push_back({ op,j.first });
                }
                cnt=j.first;
                continue;
            }
            if (j.second != 0)
            {
                while (!lo.empty())
                {
                    if (lo.front().first >= q[j.first])
                    {
                        ll c = lo.front().second;
                        ll k = lo.front().first - q[j.first];
                        cnt = j.first;
                        ans += q[j.first] * (j.first - lo.front().second);
                        q[j.first] = 0;
                        lo.pop_front();
                        if (k != 0)
                        {
                            lo.push_front({ k,c });
                        }
                        lo.push_back({ j.second,j.first });
                        break;
                    }
                    else
                    {
                        ll c = lo.front().second;
                        ll k = -lo.front().first + q[j.first];
                        cnt = j.first;
                        ans += lo.front().first * (j.first - lo.front().second);
                        q[j.first] = k;
                        lo.pop_front();
                    }
                    if(lo.empty())
                    {
                            ll op = j.second - q[j.first];
                            lo.push_back({ op,j.first });
                            cnt = j.first;
                            break;
                    }
                }
            }
            else
            {
                lo.clear();
                cnt = j.first;
                continue;
            }
        }
     //cout << ans << endl;
        if (ans % 2 == 0)
        {
            cout << "FuuFuu" << endl;
        }
        else
            cout << "Pico" << endl;
    }
}

标签:2024.10,include,训练,lo,ll,cnt,long,团队,first
From: https://www.cnblogs.com/cjcf/p/18448396

相关文章

  • 2024.10.1 近期练习
    CF1993F2Dyn-scriptedRobot(HardVersion)这个题非常的一眼,首先翻转路径的操作可以转化为翻转矩形。也就是,如果触碰了边界不改变行走的路径,而是继续走下去,只不过对应的位置需要对称回去。那么,计算走到\((0,0)\)的次数,也就是在反转后的坐标系里的\((2k_1w,2k_2h)\)的位置......
  • 2024.10.5 LGJ Round
    A给定\(n\)个区间,你要选出最多区间对数,使得每一对的区间都不交。\(n\le4e5\)。反悔贪心,我们将所有区间按\(l_i\)从小到大排序,一个一个加入,加入的时候有两种情况。1.之前的区间中存在未匹配的区间,且可以跟当前区间匹配。我们随便选择一个区间跟当前区间匹配即可。2.找不到......
  • 2024.10.5 LGJ Round
    A给定\(n\)个区间,你要选出最多区间对数,使得每一对的区间都不交。\(n\le4e5\)。反悔贪心,我们将所有区间按\(l_i\)从小到大排序,一个一个加入,加入的时候有两种情况。1.之前的区间中存在未匹配的区间,且可以跟当前区间匹配。我们随便选择一个区间跟当前区间匹配即可。2.找不到......
  • 2024.10.4(周五)
    <%@pagelanguage="java"contentType="text/html;charset=UTF-8"pageEncoding="UTF-8"%><!DOCTYPEhtml><html><head><title>工资核算信息</title><style>/*整体页面布局和样式*/......
  • 2024.10.7(周一)
    <%@pagelanguage="java"contentType="text/html;charset=UTF-8"pageEncoding="UTF-8"%><!DOCTYPEhtml><html><head><title>车间班组</title><style>/*整体页面布局和样式*/......
  • 《代码大全》阅读笔记1(2024.10.4)
    第一章:引言软件构建的艺术:介绍了软件开发的复杂性,以及编写高质量代码的重要性。强调了良好的编码习惯不仅能提高代码的可读性和可维护性,也能降低后期的开发成本。第二章:软件构建的哲学质量的重要性:讨论了软件质量的定义,强调高质量软件不仅包括功能的正确性,还包括可维护性、......
  • 2024.10.2(周三)
    <%@pagelanguage="java"contentType="text/html;charset=UTF-8"pageEncoding="UTF-8"%><!DOCTYPEhtml><html><head><title>生产工序信息</title><style>/*整体页面布局和样式*/......
  • 2024.10.1(周二)
    <%@pagelanguage="java"contentType="text/html;charset=UTF-8"pageEncoding="UTF-8"%><!DOCTYPEhtml><html><head><title>生产制令</title><style>/*整体页面布局和样式*/......
  • 2024.10.3(周四)
    <%@pagelanguage="java"contentType="text/html;charset=UTF-8"pageEncoding="UTF-8"%><!DOCTYPEhtml><html><head><title>质量检验信息</title><style>/*整体页面布局和样式*/......
  • 2024.10.5 笔记
    贪心的证明方法(5个):咕咕咕贪心、DP。贪心优化DP。有简单策略:贪心。无:DP。手玩样例。手玩。兜底。重复:copy。一行多个最小值。不管。得到答案后转成0/1。反悔贪心的一般策略:先把所有都选上,再反悔。IOI那道题和这道题。感觉反悔贪心常用堆。手写堆,支持插入、......