ZOJ 3601 Unrequited Love 【STL__pair_的应用】
下面这个例子就是 STL:pair 的用法
#include <iostream>
#include <utility>
#include <string>
using namespace std; int main () {
pair <string,double> product1 ("tomatoes",3.25);
pair <string,double> product2;
pair <string,double> product3; product2.first = "lightbulbs"; // type of first is string
product2.second = 0.99; // type of second is double product3 = make_pair ("shoes",20.0); cout << "The price of " << product1.first << " is $" << product1.second << "\n";
cout << "The price of " << product2.first << " is $" << product2.second << "\n";
cout << "The price of " << product3.first << " is $" << product3.second << "\n";
return 0;
}
这道题目使用 pair 可以非常方便的解决
Source Code:
//#pragma comment(linker, "/STACK:16777216") //for c++ Compiler
#include <stdio.h>
#include <iostream>
#include <fstream>
#include <cstring>
#include <cmath>
#include <stack>
#include <string>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <vector>
#include <algorithm>
#define Max(a,b) (((a) > (b)) ? (a) : (b))
#define Min(a,b) (((a) < (b)) ? (a) : (b))
#define Abs(x) (((x) > 0) ? (x) : (-(x)))
#define MOD 1000000007
#define pi acos(-1.0) using namespace std; typedef long long ll ;
typedef unsigned long long ull ;
typedef unsigned int uint ;
typedef unsigned char uchar ; template<class T> inline void checkmin(T &a,T b){if(a>b) a=b;}
template<class T> inline void checkmax(T &a,T b){if(a<b) a=b;} const double eps = 1e- ;
const int N = ;
const int M = * ;
const ll P = 10000000097ll ;
const int MAXN = ; map <string,int> mp;
map < pair<int,int>,int > G;
vector <string> a[];
int b[];
string str[], tmp; int main() {
int i, j, t, n, m, k, q;
scanf("%d",&t);
while (t--) {
scanf("%d %d %d",&n,&m,&q);
mp.clear();
G.clear();
for (i = ; i < n + m; ++i) {
a[i].clear();
cin >> tmp;
mp[tmp] = i;
cin >> k;
for (j = ; j < k; ++j) {
cin >> tmp;
a[i].push_back(tmp);
}
}
for (i = ; i < n + m; ++i)
for (j = ; j < a[i].size(); ++j)
G[make_pair (i,mp[a[i][j]])] = ;
while (q--) {
cin >> k;
for (i = ; i < k; ++i) {
cin >> tmp;
str[i] = tmp;
b[i] = mp[str[i]];
}
int flag;
for (i = ; i < k; ++i) {
flag = ;
for (j = ; j < k; ++j) {
if (i != j) {
if ( G[ make_pair(b[i],b[j]) ] == || G[ make_pair(b[j],b[i]) ] == ) {
flag = ;
break;
}
}
}
if (flag) {
cout << "1 " << str[i] << endl;
break;
}
}
if (!flag) cout << << endl;
}
cout << endl;
}
return ;
}
ZOJ 3601 Unrequited Love 【STL__pair_的应用】的更多相关文章
- ZOJ 3601 Unrequited Love 浙江省第九届省赛
Unrequited Love Time Limit: 16 Seconds Memory Limit: 131072 KB There are n single boys and m si ...
- zjuoj 3601 Unrequited Love
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3601 Unrequited Love Time Limit: 16 Sec ...
- zoj 3601
链接 [https://vjudge.net/contest/293343#problem/B] 题意 就是n男m女.然后给出他们喜欢那些人 再给出q次询问 每次参加party的人 让你找出某个人满足 ...
- ZOJ People Counting
第十三届浙江省大学生程序设计竞赛 I 题, 一道模拟题. ZOJ 3944http://www.icpc.moe/onlinejudge/showProblem.do?problemCode=394 ...
- ZOJ 3686 A Simple Tree Problem
A Simple Tree Problem Time Limit: 3 Seconds Memory Limit: 65536 KB Given a rooted tree, each no ...
- ZOJ Problem Set - 1394 Polar Explorer
这道题目还是简单的,但是自己WA了好几次,总结下: 1.对输入的总结,加上上次ZOJ Problem Set - 1334 Basically Speaking ac代码及总结这道题目的总结 题目要求 ...
- ZOJ Problem Set - 1392 The Hardest Problem Ever
放了一个长长的暑假,可能是这辈子最后一个这么长的暑假了吧,呵呵...今天来实验室了,先找了zoj上面简单的题目练练手直接贴代码了,不解释,就是一道简单的密文转换问题: #include <std ...
- ZOJ Problem Set - 1049 I Think I Need a Houseboat
这道题目说白了是一道平面几何的数学问题,重在理解题目的意思: 题目说,弗雷德想买地盖房养老,但是土地每年会被密西西比河淹掉一部分,而且经调查是以半圆形的方式淹没的,每年淹没50平方英里,以初始水岸线为 ...
- ZOJ Problem Set - 1006 Do the Untwist
今天在ZOJ上做了道很简单的题目是关于加密解密问题的,此题的关键点就在于求余的逆运算: 比如假设都是正整数 A=(B-C)%D 则 B - C = D*n + A 其中 A < D 移项 B = ...
随机推荐
- C#_C++_SDK_WM_KEYDOWN人物卡顿延迟解决方法
提问者采纳 由Keydown和keyup事件组合,keyDown来判定按下,此时开始移动,KeyUp判定松开,这样可行否? 追问 这是我一开始的写法,但就是因为 键盘重复延迟 导致keydown后会有 ...
- PHP-变量(www.w3school.com.cn/php)
写在前面: 变量可以形象的解释为信息的容器(存信息的东西).比如说$x=8,相当于把8给放到x里面,以后操作$x的时候就相当于操作8 >5+$x结果为13 ------------------- ...
- bmfont制作数字
http://blog.csdn.net/z104207/article/details/20136401
- qt 国际化(翻译时会触发changeEvent)
1. 修改工程文件 .pro ,加入翻译源文件 hello_world.ts: TRANSLATIONS += \ Resource/translations/hello_world.t ...
- 发一个讨论帖,如果结果被采纳的话可以给一份adb 代码,以及我封装的ADBLIB
如何在手机没有root 的情况下,获取系统的一些文件,比如 /data/data/xxxx 目录下的文件. 有任何想法的请说出来.
- HDU2795 billboard【转化为线段树。】
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2795 hhanger大神的题目,水题都得有点思维. 题意:h*w的木板,放进一些1*L的物品,求每次放 ...
- Html.text(转载)
2.Html.ValidationSummary:用来显示ModelState字典中所有验证错误的无序列表,使用布尔值类型参数(true)来告知辅助方法排除属性级别的错误,只显示ModelState中 ...
- bootstrap固定响应式导航
<link rel="stylesheet" href="http://cdn.bootcss.com/bootstrap/3.2.0/css/bootstrap. ...
- C#关键字列表
- Asp.Net MVC4.0 官方教程 入门指南之三--添加一个视图
Asp.Net MVC4.0 官方教程 入门指南之三--添加一个视图 在本节中,您需要修改HelloWorldController类,从而使用视图模板文件,干净优雅的封装生成返回到客户端浏览器HTML ...