hdu 4941 2014 Multi-University Training Contest 7 1007
Magical Forest
Time Limit: 24000/12000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others) Total Submission(s): 134 Accepted Submission(s): 69
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.
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. )
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.
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
1
2
1
No two fruits at the same location.
#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的更多相关文章
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
随机推荐
- 反射中 invoke方法 getMethod方法 getClass()方法
package com.swift; import java.util.*; import java.lang.reflect.*; public class ReflectDemo { public ...
- C# 调用腾讯地图WebService API获取距离(一对多)
官方文档地址:https://lbs.qq.com/webservice_v1/guide-distance.html 代码: /// <summary> /// 获取距离最近的点的经纬度 ...
- nodejs 静态资源服务与接口代理跨域
首先需要 npm install express 和 npm install request 代码如下: const express = require('express'); const path ...
- MySQL8.0.12安装及配置
一.下载 下载页面http://dev.mysql.com/downloads/mysql/ 选择系统平台后,点击download(根据系统选择64或32位) 二.配置 1.下载成功后,解压安装包到要 ...
- Golang TCP转发到指定地址
Golang TCP转发到指定地址 第二个版本,设置指定ip地址 代码 // tcpForward package main import ( "fmt" "net&qu ...
- Linux-缓存服务
Memcached 基本操作 解释 命令 安装 yum install memcached 启动 memcached -d -l -m -p 停止 kill pid 查看某个端口是否通:telnet ...
- C++输入密码不显示明文
之前有遇到需求说输入密码不显示明文,但同时会有一些其他问题,暂时没做,如今经过尝试可以实现,但是得先知道要输入的是密码.主要利用的getch()函数的不回显特点.需要注意的是这个函数不是标准函数,而且 ...
- iPhone如何设置自定义铃声?无需连接电脑,轻松几步就搞定!
转载自: https://baijiahao.baidu.com/s?id=1594988016778457969&wfr=spider&for=pc 受够了iPhone自带的千篇一律 ...
- 在使用sql语句的一些注意事项(sql语句)
版权声明:本文为博主原创文章,未经博主允许不得转载. 原文地址: https://www.cnblogs.com/poterliu/p/4925483.html ①如果插入字段包含对应的表的所有字段, ...
- 【linux】 服务器文件说明
文件名 说明 /etc/resolv.conf 域名解析服务器地址文件 /etc/services 服务程序对应端口号文件 /etc/passwd 登录账号文件 /etc/hosts 本地IP域名解 ...