CodeForces - 988C(STL大法好)
请你找出两个编号不同的数列,并从这两个数列中各恰好删除一个数,使得这两个数列的和相等。
用vector存每一个数
用map标记
即可
#include <bits/stdc++.h>
using namespace std;
const int maxn = , INF = 0x7fffffff;
typedef long long LL;
vector<LL> G[maxn]; //存储每一行的所有元素
map<LL, int> vis; //标记去掉某一个元素的sum是否出现
map<LL, int> x; //标记行
map<LL, int> y; //标记列 int main()
{
int k, flag = ;
cin>> k;
for(int i=; i<k; i++)
{
int n, num;
LL sum = ;
cin>> n;
for(int j=; j<n; j++)
{
cin>> num;
sum += num;
G[i].push_back(num);
}
if(!flag)
for(int j=; j<n; j++)
{
LL temp = sum - G[i][j];
if(vis[temp])
if(x[temp] == i+) continue;
else
{
cout<< "YES" <<endl;
cout<< x[temp] << " " << y[temp] <<endl;
cout<< i+ << " " << j+ <<endl;
flag = ;
break;
}
else
{
vis[temp] = ;
x[temp] = i+;
y[temp] = j+;
}
}
}
if(!flag) cout<< "NO" <<endl; return ;
}
CodeForces - 988C(STL大法好)的更多相关文章
- C++中的STL大法整理
C++中的STL大法整理 由于碰到了一些不知道怎么用的STL vector vector是数组的STL,对于普通数组的优势就在于,可以动态地变化数组长度.那么面对一些数据范围非常大而又可以边读入边处理 ...
- CodeForces 190C STL
Portal: http://codeforces.com/problemset/problem/190/C 一道卡输入输出的蛋疼题 题意:给你一个由pair和int所组成的沙茶字符串(最大含有1e5 ...
- Codeforces 997D(STL+排序)
D. Divide by three, multiply by two time limit per test 1 second memory limit per test 256 megabytes ...
- Codeforces 979D (STL set)(不用Trie简单AC)
题面: 传送门 题目大意: 给定一个空集合,有两种操作: 一种是往集合中插入一个元素x,一种是给三个数x,k,s,问集合中是否存在v,使得gcd(x,v)%k==0,且x+v<=s若存在多个满足 ...
- STL 大法好
#include <vector> 1.支持随机访问,但不支持在任意位置O(1)插入: 2.定义: ```cpp vector<int> a; ``` ...
- [codeforces 260]B. Ancient Prophesy
[codeforces 260]B. Ancient Prophesy 试题描述 A recently found Ancient Prophesy is believed to contain th ...
- STL or 线段树 --- CSU 1555: Inversion Sequence
Inversion Sequence Problem's Link: http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1555 Mean: 给你一 ...
- hdu 5265 pog loves szh II STL
pog loves szh II Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php? ...
- Codeforces Round #Pi (Div. 2) ABCDEF已更新
A. Lineland Mail time limit per test 3 seconds memory limit per test 256 megabytes input standard in ...
随机推荐
- java两年工作经验有什么经验
这两年里,了解了完整项目的开发过程,知道如何快速入手一个完全没接触过的项目:譬如先了解数据库关系后,马上熟悉一个功能从前端到后端的实现过程,自己再写一个功 能,这样子就能马上上手开发项目,之后在慢慢了 ...
- Mybatis批量更新报错com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException
批量更新数据,非常简单的一段代码,硬是报错,插入的数据也能显示出来 List<User> userlist = new ArrayList<User>(); userlist. ...
- mac 下删除行末^M 字符
在vi 打开文件模式下进行字符替换 :%s/^M/\r/g //这里的^M是同时按ctrl+v+m获得的,否则会显示找不到^M
- c++ 整数和字符串的转化
一.string转int的方式 采用最原始的string, 然后按照十进制的特点进行算术运算得到int,但是这种方式太麻烦,这里不介绍了. 采用标准库中atoi函数. "; int a = ...
- BugPhobia开发篇章:Alaph阶段Scurm Meeting
[github] https://github.com/bugphobia/XuebaOnline 0x01 :目录与摘要 If you weeped for the missing sunset ...
- 修复webpack自动刷新页面慢的问题
新建.babelrc文件,配置如下 { "presets": [ "es2015" ], "ignore":[ "react-ro ...
- 进阶系列(2)—— C#集合
一.集合介绍 集合是.NET FCL(Framework Class Library)的重要组成部分,我们平常撸C#代码时免不了和集合打交道,FCL提供了丰富易用的集合类型,给我们撸码提供了极大的便利 ...
- Leetcode题库——33.搜索旋转排序数组
@author: ZZQ @software: PyCharm @file: search.py @time: 2018/11/12 18:12 要求:假设按照升序排序的数组在预先未知的某个点上进行了 ...
- 调研Android的开发环境的发展演变
在 知道要做基于移动端的项目实践时,我就选定了Android,回来的时候查了很多相关的知识,很多人都在问开发安卓软件,使用eclipse还是用 Android studio?其实,也没有一个准确的答案 ...
- BNUOJ 52303 Floyd-Warshall Lca+bfs最短路
题目链接: https://www.bnuoj.com/v3/problem_show.php?pid=52303 Floyd-Warshall Time Limit: 60000msMemory L ...