Magical Forest

Time Limit: 24000/12000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) Total Submission(s): 134    Accepted Submission(s): 69

Problem Description
   There is a forest can be seen as N * M grid. In this forest, there is some magical fruits, These fruits can provide a lot of energy, Each fruit has its location(Xi, Yi) and the energy can be provided Ci.
   However, the forest will make the following change sometimes:       1. Two rows of forest exchange.       2. Two columns of forest exchange.    Fortunately, two rows(columns) can exchange only if both of them contain fruits or none of them contain fruits.
   Your superior attach importance to these magical fruit, he needs to know this forest information at any time, and you as his best programmer, you need to write a program in order to ask his answers quick every time.
 
Input
   The input consists of multiple test cases.
   The first line has one integer W. Indicates the case number.(1<=W<=5)
   For each case, the first line has three integers N, M, K. Indicates that the forest can be seen as maps N rows, M columns, there are K fruits on the map.(1<=N, M<=2*10^9, 0<=K<=10^5)
   The next K lines, each line has three integers X, Y, C, indicates that there is a fruit with C energy in X row, Y column. (0<=X<=N-1, 0<=Y<=M-1, 1<=C<=1000)
   The next line has one integer T. (0<=T<=10^5)    The next T lines, each line has three integers Q, A, B.    If Q = 1 indicates that this is a map of the row switching operation, the A row and B row exchange.    If Q = 2 indicates that this is a map of the column switching operation, the A column and B column exchange.    If Q = 3 means that it is time to ask your boss for the map, asked about the situation in (A, B).    (Ensure that all given A, B are legal. )
 
Output
   For each case, you should output "Case #C:" first, where C indicates the case number and counts from 1.
   In each case, for every time the boss asked, output an integer X, if asked point have fruit, then the output is the energy of the fruit, otherwise the output is 0.
 
Sample Input
1
3 3 2
1 1 1
2 2 2
5
3 1 1
1 1 2
2 1 2
3 1 1
3 2 2
 
Sample Output
Case #1:
1
2
1

Hint

No two fruits at the same location.

 
Author
UESTC
 
Source
 
Recommend
We have carefully selected several similar problems for you:  4944 4943 4942 4941 4940 
 
 
思路:stl。。。
 #include<iostream>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<queue>
#include<map>
//#include<pair> #define N 1505
#define M 105
#define mod 1000000007
#define mod2 100000000
#define ll long long
#define maxi(a,b) (a)>(b)? (a) : (b)
#define mini(a,b) (a)<(b)? (a) : (b) using namespace std; map<pair<int,int>,int>v;
map<int,int>X,Y;
int n,m,k;
int q,a,b;
int x,y,c;
int tt;
int T; int main()
{
// freopen("data.in","r",stdin);
scanf("%d",&T);
for(int cnt=;cnt<=T;cnt++)
//while(T--)
//while(scanf("%d%d",&n,&m)!=EOF)
{
//
printf("Case #%d:\n",cnt);
v.clear();X.clear();Y.clear();
scanf("%d%d%d",&n,&m,&k);
while(k--){
scanf("%d%d%d",&x,&y,&c);
v[make_pair(x,y)]=c;
// printf(" %d %d %d\n",x,y,c);
X[x]=x;
Y[y]=y;
// printf(" %d:%d %d:%d\n",x,X[x],y,Y[y]);
}
scanf("%d",&tt);
while(tt--)
{
scanf("%d%d%d",&q,&a,&b);
if(q==){
swap(X[a],X[b]);
//printf(" %d:%d %d:%d\n",a,X[a],b,X[b]);
}
else if(q==){
swap(Y[a],Y[b]);
// printf(" %d:%d %d:%d\n",a,Y[a],b,Y[b]);
}
else{
printf("%d\n",v[make_pair(X[a],Y[b])]);
} } } return ;
}

hdu 4941 2014 Multi-University Training Contest 7 1007的更多相关文章

  1. hdu 4915 Parenthese sequence--2014 Multi-University Training Contest 5

    主题链接:http://acm.hdu.edu.cn/showproblem.php?pid=4915 Parenthese sequence Time Limit: 2000/1000 MS (Ja ...

  2. hdu 4902 Nice boat--2014 Multi-University Training Contest 4

    题目链接:http://acm.hdu.edu.cn/showproblem.php? pid=4902 Nice boat Time Limit: 30000/15000 MS (Java/Othe ...

  3. hdu 4925 Apple Tree--2014 Multi-University Training Contest 6

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4925 Apple Tree Time Limit: 2000/1000 MS (Java/Others ...

  4. HDU校赛 | 2019 Multi-University Training Contest 6

    2019 Multi-University Training Contest 6 http://acm.hdu.edu.cn/contests/contest_show.php?cid=853 100 ...

  5. HDU校赛 | 2019 Multi-University Training Contest 5

    2019 Multi-University Training Contest 5 http://acm.hdu.edu.cn/contests/contest_show.php?cid=852 100 ...

  6. HDU校赛 | 2019 Multi-University Training Contest 4

    2019 Multi-University Training Contest 4 http://acm.hdu.edu.cn/contests/contest_show.php?cid=851 100 ...

  7. HDU校赛 | 2019 Multi-University Training Contest 3

    2019 Multi-University Training Contest 3 http://acm.hdu.edu.cn/contests/contest_show.php?cid=850 100 ...

  8. HDU校赛 | 2019 Multi-University Training Contest 2

    2019 Multi-University Training Contest 2 http://acm.hdu.edu.cn/contests/contest_show.php?cid=849 100 ...

  9. HDU校赛 | 2019 Multi-University Training Contest 1

    2019 Multi-University Training Contest 1 http://acm.hdu.edu.cn/contests/contest_show.php?cid=848 100 ...

随机推荐

  1. 如何使用公网ip访问部署在云服务器的web项目

    我使用的是华为云服务器,已经在服务器上部署好项目,现在想要通过外网访问服务器的话,需要配置一下安全组:1.依据下图找到安全组,点击教我设置: 2. 进入安全组配置示例,根据自己的需要选择不同的配置方案 ...

  2. 设置通过Maven创建的工程的JDK的版本,更改conf/settings.xml

    eclipse提示警告如下: Build path specifies execution environment J2SE-1.5. There are no JREs installed in t ...

  3. LeetCode之Weekly Contest 90

    LeetCode第90场周赛记录 第一题:亲密字符串 问题: 给定两个由小写字母构成的字符串 A 和 B ,只要我们可以通过交换 A 中的两个字母得到与 B 相等的结果,就返回 true :否则返回  ...

  4. python日记整理

    都是自己的学习总结,要是总结的有问题大佬麻烦评价一下我好修改,谢谢 python插件插件+pycharm基本用法+markdown文本编写+jupyter notebook的基本操作汇总 一.计算机基 ...

  5. Python9-网络编程3-day32

    解决黏包的问题 #server import socket sk = socket.socket() sk.bind(('127.0.0.1',8080)) sk.listen() conn,addr ...

  6. 【Shell】使用shell打印菜单,一键安装Web应用

    问题描述: [解答] [root@A04-Test- scripts]# more menu.sh #!/bin/bash echo "1.[install lamp]" echo ...

  7. python - 函数的相互调用 及 变量的作用域

    # -*- coding:utf-8 -*- '''@project: jiaxy@author: Jimmy@file: study_函数的相互调用及变量的作用域.py@ide: PyCharm C ...

  8. day05_05 for循环、break语句

    1.0 输入用户名,密码练习 _user = "alex" _passwd = "abc123" username = input("Username ...

  9. 使mysql的表内容可以输入中文内容

    修改数据库的字符集mysql>use mydb mysql>alter database mydb character set utf8;

  10. Python IO多路复用select模块

    多路复用的分析实例:服务端.客户端 #服务端配置 from socket import * import time import select server = socket(AF_INET, SOC ...