Codeforces Round #285 (Div. 2) ABC

A - Contest; cf算分..int即可

#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    int q, w, e, r;
    while(~scanf("%d%d%d%d", &q, &w, &e, &r))
    {
        int z = max( q * 3 / 10, q - q / 250 * e );
        int x = max( w * 3 / 10, w - w / 250 * r );
        if( z > x )
            puts("Misha");
        else if( z < x )
            puts("Vasya");
        else
            puts("Tie");
    }
    return 0;
}
B - Misha and Changing Handles 求最开始的原名和最后的化名有多少对并输出

#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

map < string, string > mp;
map < string, string > :: iterator it; 
string cc, dd;

void init()
{
    mp.clear();
}

int main()
{
    int n;
    cin.sync_with_stdio(0);
    while( cin >> n )
    {
        init();
        while( n-- )
        {
            cin >> cc >> dd;
            it = mp.find(cc);
            if( it == mp.end() )
            {
                mp[dd] = cc;
            }
            else
            {
                mp[dd] = it->second;
                mp.erase(it);
            }
        }
        cout << mp.size() << endl;
        map < string, string > :: iterator it;
        for( it = mp.begin(); it != mp.end(); it++ )
        {
            cout << it->second << " " << it->first  << endl;
        }
    }
    return 0;
}

C - Misha and Forest :给出森林的每个点的度数及其叶子节点的异或和,求出每条边的两点。异或和即为,比如1的相邻点有2 3 4,那么就是a = 2 ^ 3 ^ 4。

#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;
const int N = 1000010;

struct node{
	int u, v;
}e[N];
int cnt;
int d[N], f[N];
stack<int> q;

int main()
{
    int n;
    while(~scanf("%d", &n))
	{
		while( !q.empty() )
			q.pop();
		cnt = 0;
		for( int i = 0; i < n; i++ )
		{
			scanf("%d%d", &d[i], &f[i]);
			if( d[i] == 1 )
				q.push(i);
		}
		while( !q.empty() )
		{
			int now = q.top();
			q.pop();
			if( d[now] != 1 )
				continue;
			int tmp = f[now];
			e[cnt].u = now;
			e[cnt++].v = tmp;
			d[tmp]--;
			f[tmp] ^= now;
			if( d[tmp] == 1 )
				q.push(tmp);
		}
		printf("%d\n", cnt);
		for( int i = 0; i < cnt; i++ )
			printf("%d %d\n", e[i].u, e[i].v);
	}
    return 0;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值