跳过正文
  1. Posts/

codeforces #346 div 2 B. Qualifying Contest (排序)

·2 分钟

题目链接 题意:给出选手个数n,下面n行每个选手的信息“名字 区域编号 分数”.保证每个区域至少两个选手。问每个区域能否唯一确定一支二人的队伍(尽可能选分数高的,当要选的人里有分数相同的则不能确定。 思路:排序啊。。。然后搞啊。。结果发现思路没缕清。。。在某一个区域中,决定是否能唯一确定队伍的是第二个人和第三个人的成绩,和第一个人无关。 特殊处理一个区域只有两个人参加的,这种情况肯定能唯一确定队伍。 妈蛋,这种傻逼题卡了一个小时。。。。

 1/* ***********************************************
 2Author :111qqz
 3Created Time :2016年03月31日 星期四 16时00分23秒
 4File Name :code/cf/#346/BB.cpp
 5************************************************ */
 6
 7#include <cstdio>
 8#include <cstring>
 9#include <iostream>
10#include <algorithm>
11#include <vector>
12#include <queue>
13#include <set>
14#include <map>
15#include <string>
16#include <cmath>
17#include <cstdlib>
18#include <ctime>
19#define fst first
20#define sec second
21#define lson l,m,rt<<1
22#define rson m+1,r,rt<<1|1
23#define ms(a,x) memset(a,x,sizeof(a))
24typedef long long LL;
25#define pi pair < int ,int >
26#define MP make_pair
27
28using namespace std;
29const double eps = 1E-8;
30const int dx4[4]={1,0,0,-1};
31const int dy4[4]={0,-1,1,0};
32const int inf = 0x3f3f3f3f;
33const int N=1E5+7;
34int n;
35int m;
36int cnt[N];
37
38struct node
39{
40    string nam;
41    int s;
42    bool operator <(node b)const
43    {
44	return s>b.s;
45    }
46};
47
48vector<node>v[N];
49int main()
50{
51	#ifndef  ONLINE_JUDGE
52	freopen("code/in.txt","r",stdin);
53  #endif
54
55	cin>>n>>m;
56	ms(cnt,0);
57	for ( int i = 1 ; i <= n ; i++)
58	{
59	    string nam;
60	    node tmp;
61	    int x,y;
62	    cin>>nam>>x>>y;
63	    tmp.nam = nam;
64	    tmp.s = y;
65	    v[x].push_back(tmp);
66	}
67
68	for ( int i = 1 ; i <= m ; i++)   //终点是第二个和第三个不能相等,和第一个没什么关系...
69	{				    //就算前两个相等,只要第二个不和第三个相等,那也有唯一解。
70	    sort(v[i].begin(),v[i].end());
71
72	    if (v[i].size()==2)
73	    {
74		cout<<v[i][0].nam<<" "<<v[i][1].nam<<endl;
75		continue;
76	    }
77	    if (v[i][1].s==v[i][2].s)
78	    {
79		puts("?");
80		continue;
81	    }
82	    cout<<v[i][0].nam<<" "<<v[i][1].nam<<endl;
83	}
84
85  #ifndef ONLINE_JUDGE
86  fclose(stdin);
87  #endif
88    return 0;
89}

相关文章

codeforces 612 D. The Union of k-Segments

·2 分钟
http://codeforces.com/contest/612/problem/D 题意:给出n个线段信息,每个线段以l,r的形式给出。给定k。要求从作到右给出至少有k个线段覆盖的区间的信息。并使得区间数目尽可能少。

codeforces #346 div 2 A. Round House

·1 分钟
题目链接 水题 乱搞。 1/* *********************************************** 2Author :111qqz 3Created Time :2016年03月30日 星期三 23时59分47秒 4File Name :code/cf/#346/A.cpp 5************************************************ */ 6 7#include <cstdio> 8#include <cstring> 9#include <iostream> 10#include <algorithm> 11#include <vector> 12#include <queue> 13#include <set> 14#include <map> 15#include <string> 16#include <cmath> 17#include <cstdlib> 18#include <ctime> 19#define fst first 20#define sec second 21#define lson l,m,rt<<1 22#define rson m+1,r,rt<<1|1 23#define ms(a,x) memset(a,x,sizeof(a)) 24typedef long long LL; 25#define pi pair < int ,int > 26#define MP make_pair 27 28using namespace std; 29const double eps = 1E-8; 30const int dx4[4]={1,0,0,-1}; 31const int dy4[4]={0,-1,1,0}; 32const int inf = 0x3f3f3f3f; 33int n,a,b; 34int main() 35{ 36 #ifndef ONLINE_JUDGE 37 freopen("code/in.txt","r",stdin); 38 #endif 39 cin>>n>>a>>b; 40 a = a + b; 41 while (a<=0) a+=n; 42 while (a>n) a-=n; 43 cout<<a<<endl; 44 45 #ifndef ONLINE_JUDGE 46 fclose(stdin); 47 #endif 48 return 0; 49}

codeforces 652 B. z-sort (简单构造)

·1 分钟
题目链接 题意:给出n个元素的序列,问能否得到一个新的序列,使得奇数位置非递减排列,偶数位数非递增排列。 思路:感觉一定可以啊。。。排序以后直接构造。。。