/*
学acwing的算法基础课学来的,喜欢的话多多支持呀。
*/
#include<bits/stdc++.h>//c++万能头文件
#pragma GCC optimize(2)//c++ o2优化,加快处理时间
using namespace std;
typedef pair<int,int>PII;
typedef unsigned long long ull;
typedef long long LL;
const int M=2010;
const int INF=0x3f3f3f3f;
const int mod=1e9+7;
const int N=2e5+10;
int dx[4]={0,1,0,-1};
int dy[4]={-1,0,1,0};
void solve()
{
//要解决的问题
}
int main()
{
//总体来说scanf与printf快一点
ios_base::sync_with_stdio(0);//cin的快速读入,用了这个就不能用scanf,而且printf会比cout输出先,不管二者顺序
cin.tie(0);//快读
cout.tie(0);//快输
freopen("test.in","r",stdin);//用文件来测试数据
int t;cin>>t;
while(t--)solve();
return 0;
}
/*到达胜利之前无法回头*/
//读入一行的数,不知道数的个数
方法一:
string tmp;
getline(cin, tmp);
stringstream ssin(tmp);
vector <string> s;
while (ssin >> tmp) s.push_back(tmp);
int l=atoi(s[0].c_str())+1;//因为下标是从0开始的,所以要+1
int r=atoi(s[1].c_str())+1;
方法二:
vector<int> tmp;
int x;
while(cin >> x)
{
tmp.push_back(x);
if (cin.get() == '\n')
break;
}
方法三:
string s; getline(cin, s);
auto nums = split(s);
//去重
sort(v.begin(),v.end());
v.erase(unique(v.begin(), v.end()), v.end());
//蓝桥杯对拍测试代码
//baoli.cpp
freopen("in.in", "r", stdin); //读入数据生成器造出来的数据
freopen("baoli.txt", "w", stdout); //输出答案
//std.cpp
freopen("in.in", "r", stdin);
freopen("std.txt", "w", stdout);
//data.cpp
srand((unsigned)time(0));
freopen("in.in", "w", stdout); //生成 使两份基本代码 将要读入的数据
//test.cpp
#include <cstdio>
#include <cstdlib>
#include <ctime>
using namespace std;
int main()
{
while (1) //一直循环,直到找到不一样的数据
{
system("data.exe");
system("baoli.exe");
system("std.exe");
if (system("fc std.txt baoli.txt")) //当 fc 返回1时,说明这时数据不一样
break; //不一样就跳出循环
break;
}
return 0;
}
//测试运行时间
clock_t start_time=clock();
//代码
clock_t end_time=clock();
if((double)(end_time-start_time)/CLOCKS_PER_SEC*1000.0>=1000.0) puts("-1");//1s的时长
关于lower_bound( )和upper_bound( )的常见用法
(7条消息) 关于lower_bound( )和upper_bound( )的常见用法_brandong的博客-CSDN博客
//重定义排序
struct Node
{
int x,y,c;
bool operator < (const Node &t) const//自定义小于号
{
return x>t.x;//返回需要的排序
}
};