---------STL---------
文章平均质量分 66
Werky_blog
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
UVa 12216 表达式树,map(不会)
https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=244&page=show_problem&problem=3371 #include #include #include using namespace std; const int maxn = 60000; int T, kas原创 2017-09-21 21:50:47 · 242 阅读 · 0 评论 -
蓝桥杯 PREV-39日期问题(set的迭代器应用)
题目:点击打开链接思路:模拟一下即可,把符合条件的插入set,要用set对插入的结构体自动排序就要在结构体里重载<运算符,输出函数也写在结构体里,用迭代器输出。要实现去重,还要写构造函数自动赋值和判断是否合法。但我没不太会那么写,发现不能判重后手动写了一个很蠢的方式。然后发现set的iterator it不能it-1,于是就很蠢的先--再++。然后还发现蓝桥不能用auto。#include&...原创 2018-03-29 16:06:32 · 265 阅读 · 0 评论 -
L2-023 (假)图着色问题 set去重
题目:https://www.patest.cn/contests/gplt/L2-023竟然是必须用k种,少用了还不行。#include <bits/stdc++.h> #define ll long long int using namespace std; const int maxn=100005; struct node{ int v,u; }edge[250005...原创 2018-03-11 17:17:39 · 383 阅读 · 0 评论 -
L2-021 点赞狂魔 map
题目:https://www.patest.cn/contests/gplt/L2-021#include <bits/stdc++.h> #define ll long long int using namespace std; const int maxn=100005; struct node{ char name[10]; int num; float...原创 2018-03-11 15:53:26 · 426 阅读 · 0 评论 -
L2-020 vector模拟
题目:https://www.patest.cn/contests/gplt/L2-020写成这样也过了。。。就是没用double wa了半天#include <bits/stdc++.h> #define ll long long int using namespace std; const int maxn=100005; vector<int > v[maxn]; ...原创 2018-03-11 14:58:57 · 201 阅读 · 0 评论 -
L2-019 map
题目:https://www.patest.cn/contests/gplt/L2-019#include <bits/stdc++.h> using namespace std; map <string,int> m; vector <string> v; int main(){ int n,k,num; cin>>n; ...原创 2018-03-11 10:49:38 · 163 阅读 · 0 评论 -
L2-002 集合相似度(set)
题目:https://www.patest.cn/contests/gplt/L2-005题意:Nc=2: 87,101 Nt=4 : 87,101,99,5#include<bits/stdc++.h> using namespace std; set <int> s[55]; int a,b; void fun(){ int same=0; se...原创 2018-03-06 20:33:22 · 408 阅读 · 0 评论 -
hdu 2094 谁是冠军(STL,拓扑排序)
题目:http://acm.hdu.edu.cn/showproblem.php?pid=2094 这题简直太水了,开始觉得拓扑,后来写着写着发现大部分代码没用,就删成这样了。只要入度唯一即可输出yes stl是真好用,特别是auto定义迭代器遍历map,set等。 但是这题确实写错了,光写flag没判断入度均不为0时,应该是No,而之前写的忘判断flag==0时size是不是0; #原创 2017-09-29 21:46:03 · 346 阅读 · 0 评论 -
1054 map<int,int>
#include #include #include #include #include #include using namespace std; int main(){ int m,n,a,b; map mm; //原来用map在于下标很大时不用开到那么大 scanf("%d%d",&m,&n); for(int i=0;i<n;i++) f原创 2017-09-10 21:34:16 · 542 阅读 · 0 评论 -
1047 vector
这就是1039的反转,结果我还是超时了。。。 就没有学会用int存吗?不知道string很慢吗? #include #include #include #include #include #include using namespace std; int main(){ int n,k,a,b; string s; scanf("%d%d",&n,&k); v原创 2017-09-10 20:50:09 · 210 阅读 · 0 评论 -
1039 vector+hash
果然最后一组超时: #include #include #include #include #include #include using namespace std; int main(){ int n,k,a,b; string str; scanf("%d%d",&n,&k); map > m; for(int i=0;i<k;i++){转载 2017-09-10 20:06:52 · 376 阅读 · 0 评论 -
1022 数字图书馆
贼牛,这我可写不出来,STL不6根本无从下手 /* 用map将ID和其信息()string连起来,ID存在set。可以自动排序 然后用find找出来,用迭代器输出存储的的满足信息的ID 其实每个key都是一个键,只不过一次输了好多个,和title等是一样的,只不过中间没有空格 */ #include #include #include #include #include #include usi转载 2017-09-10 16:54:35 · 251 阅读 · 0 评论 -
1016 (STL)
/* 原来他只会显示一个月的账单,不存在有两个月的 用node存输入数据,建立一个vector存node,排好序,建立map把对应数据存到名字下(开始跟着挂断时间) 用auto建立迭代器,循环map */ #include #include #include #include #include using namespace std; struct node{ string name;转载 2017-09-10 12:41:10 · 265 阅读 · 0 评论 -
UVa156 map
#include<iostream> #include<map> #include<string> #include<vector> #include<algorithm> #include<cctype> using namespace std; map<string,int> cnt; vector&原创 2017-09-08 16:46:08 · 215 阅读 · 0 评论 -
hdu 5878 丑数 STL(pair,priority_queue)
原来把算的数存起来需要时再输出就叫打表,先写个代码找找maxn http://blog.youkuaiyun.com/qq_22497299/article/details/52565561 但我其实想学STL,先挖个坑吧。。。转载 2017-09-08 23:20:33 · 278 阅读 · 0 评论 -
UVa 10815 set
找出所有不同的单词,按字典序从小到大输出。Sample InputAdventures in Disneyland Two blondes were going to Disneyland when they came to a fork in the road. The sign read: "Disneyland Left." So they went home.#include<i...原创 2017-09-08 16:21:45 · 268 阅读 · 0 评论 -
1025 排序(vector存结构体)
竟然还有不足13位的id,要补0,怪不得最后一个测试点不过,,, /* 先把local的序排好,存到总的vector里 再sort总的 */ #include #include #include #include #include using namespace std; int temp[1005],a[1005]; struct student{ int score,loc,loc转载 2017-09-14 23:43:05 · 249 阅读 · 0 评论 -
Codeforces #478 D Ghosts
题目:http://codeforces.com/contest/975/problem/D题意:给你一条直线,给你直线上的几个点及其方向,构成几个向量。问你这几个向量上的直线相交几次,结果乘以2.思路:分析发现,就是求这个点构成的直线与之前直线的相交次数,即斜率(方向)不相等的直线数。sync_with_stdio这个函数是一个“是否兼容stdio”的开关,C++为了兼容C,保证程序在使用了st...原创 2018-05-09 20:29:16 · 232 阅读 · 0 评论
分享