CodeForces#285 div.2 题解

本文详细阐述了如何通过公式计算并比较两个人的成绩,并提供了代码实现。包括A题的比较成绩逻辑,B题的排序与更新逻辑,以及C题的未完成部分。重点在于算法与数据结构的应用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

A题:

题意:给出两个人的提交时间和题目的初始分数,比较两人的成绩的高低

思路:根据公式模拟即可max(3*p/10,p-p/250*t)

下面是A题代码:

#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <vector>
#include <deque>
#include <list>
#include <cctype>
#include <algorithm>
#include <climits>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <set>
#include <iomanip>
#include <cstdlib>
#include <ctime>
#define ll long long
#define ull unsigned long long
#define all(x) (x).begin(), (x).end()
#define clr(a, v) memset( a , v , sizeof(a) )
#define pb push_back
#define mp make_pair
#define read(f) freopen(f, "r", stdin)
#define write(f) freopen(f, "w", stdout)
using namespace std;
const double pi = acos(-1);

int main()
{
    ios::sync_with_stdio( false );

    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int ans_1, ans_2;
    ans_1 = max ( 3 * a / 10, a - a / 250 * c );
    ans_2 = max ( 3 * b / 10, b - b / 250 * d );
    if ( ans_1 > ans_2 ){
        cout << "Misha" << endl;
    }
    else if ( ans_1 < ans_2 ){
        cout << "Vasya" << endl;
    }
    else if ( ans_1 == ans_2 ){
        cout << "Tie" << endl;
    }

    return 0;
}


B题:

题意:给出一个数字n,下面有n组数据,每组数据表示一个人的旧名称和新名称,按新名称升序排序,输出初始名称(最早)和当前名称(最新)。

思路:暴力查询、更新即可

#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <vector>
#include <deque>
#include <list>
#include <cctype>
#include <algorithm>
#include <climits>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <set>
#include <iomanip>
#include <cstdlib>
#include <ctime>
#define ll long long
#define ull unsigned long long
#define all(x) (x).begin(), (x).end()
#define clr(a, v) memset( a , v , sizeof(a) )
#define pb push_back
#define mp make_pair
#define read(f) freopen(f, "r", stdin)
#define write(f) freopen(f, "w", stdout)
using namespace std;
const double pi = acos(-1);

struct name{
    string a, b;
    name(){}
    name(string a, string b){
        this->a = a;
        this->b = b;
    }
    friend bool operator < ( const name &a, const name &b ){
        return a.b < b.b;
    }
};

int main()
{
    ios::sync_with_stdio( false );
    vector<name> num;
    int n;
    cin >> n;
    string a, b;
    cin >> a >> b;
    num.push_back ( name(a,b) );
    for ( int i = 1; i < n; i ++ ){
        cin >> a >> b;
        int j;
        for ( j = 0; j < num.size(); j ++ ){
            if ( a == num[j].b ){
                num[j].b = b;
                break;
            }
            if ( b == num[j].a ){
                num[j].a = a;
                break;
            }
        }
        if ( j == num.size() ){
            num.push_back ( name( a, b ) );
        }
    }
    sort ( num.begin(), num.end() );
    cout << num.size() << endl;
    for ( int i = 0; i < num.size(); i ++ ){
        cout << num[i].a << ' ' << num[i].b << endl;
    }
    return 0;
}

C题:

(未完待续)



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值