A

#include <bits/stdc++.h>
#define PI acos(-1.0)
#define mem(a,b) memset((a),b,sizeof(a))
#define TS printf("!!!\n")
#define pb push_back
#define inf 0x3f3f3f3f
//std::ios::sync_with_stdio(false);
using namespace std;
//priority_queue<int,vector<int>,greater<int>> que; get min
const double eps = 1.0e-10;
const double EPS = 1.0e-4;
typedef pair<int, int> pairint;
typedef long long ll;
typedef unsigned long long ull;
//const int maxn = 3e5 + 10;
const int turn[][] = {{, }, { , }, { , -}, { -, }};
//priority_queue<int, vector<int>, less<int>> que;
//next_permutation
int num[];
int main()
{
vector<int> ans;
int minn=2e9;
int n;
cin >> n;
for(int i=;i<=n;i++)
{
scanf("%d",&num[i]);
minn=min(minn,num[i]);
}
for(int i=;i<=n;i++)
{
if(num[i]==minn)
{
ans.push_back(i);
}
}
int anser=1e9;
for(int i=;i<ans.size()-;i++)
{
anser=min(anser,ans[i+]-ans[i]);
}
cout<<anser<<endl;
}

B

#include <bits/stdc++.h>
#define PI acos(-1.0)
#define mem(a,b) memset((a),b,sizeof(a))
#define TS printf("!!!\n")
#define pb push_back
#define inf 0x3f3f3f3f
//std::ios::sync_with_stdio(false);
using namespace std;
//priority_queue<int,vector<int>,greater<int>> que; get min
const double eps = 1.0e-10;
const double EPS = 1.0e-4;
typedef pair<int, int> pairint;
typedef long long ll;
typedef unsigned long long ull;
//const int maxn = 3e5 + 10;
const int turn[][] = {{, }, { , }, { , -}, { -, }};
//priority_queue<int, vector<int>, less<int>> que;
//next_permutation
int num[];
int main()
{
int n,a,b;
cin >> n >> a >> b;
for(int i=min(a,b);;i--)
{
if(a/i+b/i>=n)
{
cout<<i<<endl;
return ;
}
}
}

C

我们知道当三个里面的最小值都大于三的时候肯定不行 当有一个为1的时候肯定行 当2的个数不小于两个的时候肯定行 三个全为3也肯定行

剩下的就是 244这种情况

#include <bits/stdc++.h>
#define PI acos(-1.0)
#define mem(a,b) memset((a),b,sizeof(a))
#define TS printf("!!!\n")
#define pb push_back
#define inf 0x3f3f3f3f
//std::ios::sync_with_stdio(false);
using namespace std;
//priority_queue<int,vector<int>,greater<int>> que; get min
const double eps = 1.0e-10;
const double EPS = 1.0e-4;
typedef pair<int, int> pairint;
typedef long long ll;
typedef unsigned long long ull;
//const int maxn = 3e5 + 10;
const int turn[][] = {{, }, { , }, { , -}, { -, }};
//priority_queue<int, vector<int>, less<int>> que;
//next_permutation
int num[];
int main()
{
int a, b, c;
cin >> a >> b >> c;
num[a]++, num[b]++, num[c]++;
if (min(min(a, b), c) == )
{
cout << "YES" << endl;
return ;
}
if (num[] == && num[] == )
{
cout << "YES" << endl;
return ;
}
if (num[] >= || num[] == )
{
cout << "YES" << endl;
return ;
}
cout << "NO" << endl;
}

D

假设一个区间内的逆序对数为N 区间为L-R 则不为逆序对的数翻转之后会变成逆序对 本为逆序对的翻转之后变成正常 而1-L -1 R+1-N的逆序对并不会受到影响

所以最终的答案就是SUM-N+(R-L+1)*(R-L)/2-N=SUM+(R-L+1)*(R-L)/2-2*N 因为2*N肯定是偶数 减去不影响答案的奇偶性 所以只要判断(R-L+1)*(R-L)/2是奇数还是偶数就行

#include <bits/stdc++.h>
#define PI acos(-1.0)
#define mem(a,b) memset((a),b,sizeof(a))
#define TS printf("!!!\n")
#define pb push_back
#define inf 0x3f3f3f3f
//std::ios::sync_with_stdio(false);
using namespace std;
//priority_queue<int,vector<int>,greater<int>> que; get min
const double eps = 1.0e-10;
const double EPS = 1.0e-4;
typedef pair<int, int> pairint;
typedef long long ll;
typedef unsigned long long ull;
//const int maxn = 3e5 + 10;
const int turn[][] = {{, }, { , }, { , -}, { -, }};
//priority_queue<int, vector<int>, less<int>> que;
//next_permutation
int num[];
int c[][];
int dp[][];
ll sum = ;
int main()
{
int n;
cin >> n;
for (int i = ; i <= n; i++)
{
scanf("%d", &num[i]);
}
for (int i = ; i <= n; i++)
{
for (int j = num[i] - ; j >= ; j--)
{
c[i][j]++;
}
}
for (int i = ; i <= n; i++)
{
for (int j = ; j <= n; j++)
{
c[j][i] += c[j - ][i];
}
}
for (int i = ; i <= n; i++)
{
sum += c[i - ][num[i]];
}
int flag;
if(sum%)
flag=;
else
flag=;
int q;
cin >> q;
while (q--)
{
int l,r;
cin >> l >> r;
if(((r-l+)*(r-l)/)%)
flag^=;
if(flag)
cout<<"odd"<<endl;
else
cout<<"even"<<endl;
}
}

E

#include <bits/stdc++.h>

#define PI acos(-1.0)
#define mem(a,b) memset((a),b,sizeof(a))
#define TS printf("!!!\n")
#define pb push_back
#define inf 0x3f3f3f3f
//std::ios::sync_with_stdio(false);
using namespace std;
//priority_queue<int,vector<int>,greater<int>> que; get min
const double eps = 1.0e-10;
const double EPS = 1.0e-4;
typedef pair<int, int> pairint;
typedef long long ll;
typedef unsigned long long ull;
//const int maxn = 3e5 + 10;
const int turn[][] = {{, }, { , }, { , -}, { -, }};
//priority_queue<int, vector<int>, less<int>> que;
//next_permutation
int anser[];
int num[];
int visit[];
stack<int> sta;
vector<int> ans;
int main()
{
int cur = ;
int n, m;
cin >> n >> m;
for (int i = ; i <= m; i++)
{
cin >> num[i];
anser[i] = num[i];
visit[num[i]] = ;
sta.push(num[i]);
while (sta.size() && cur == sta.top())
{
sta.pop();
cur++;
}
}
int now;
while (cur <= n || (!sta.empty() && sta.top() > cur))
{
if (sta.size())
{
now = sta.top();
}
else
{
now = n + ;
}
for (int i = now - ; i >= cur; i--)
{
if (visit[i])
{
cout << - << endl;
return ;
}
else
{
anser[++m] = i;
sta.push(i);
visit[i] = ;
}
}
while (sta.size() && cur == sta.top())
{
sta.pop();
cur++;
}
}
if (sta.size())
{
cout << - << endl;
return ;
}
for (int i = ; i <= n; i++)
{
cout << anser[i] << " ";
}
cout << endl;
}

Codeforces 911 三循环数覆盖问题 逆序对数结论题 栈操作模拟的更多相关文章

  1. Codeforces 351B Jeff and Furik:概率 + 逆序对【结论题 or dp】

    题目链接:http://codeforces.com/problemset/problem/351/B 题意: 给你一个1到n的排列a[i]. Jeff和Furik轮流操作,Jeff先手. Jeff每 ...

  2. 归并排序(归并排序求逆序对数)--16--归并排序--Leetcode面试题51.数组中的逆序对

    面试题51. 数组中的逆序对 在数组中的两个数字,如果前面一个数字大于后面的数字,则这两个数字组成一个逆序对.输入一个数组,求出这个数组中的逆序对的总数. 示例 1: 输入: [7,5,6,4] 输出 ...

  3. hdu 4911 求逆序对数+树状数组

    http://acm.hdu.edu.cn/showproblem.php?pid=4911 给定一个序列,有k次机会交换相邻两个位置的数,问说最后序列的逆序对数最少为多少. 实际上每交换一次能且只能 ...

  4. bzoj 3744 Gty的妹子序列 区间逆序对数(在线) 分块

    题目链接 题意 给定\(n\)个数,\(q\)个询问,每次询问\([l,r]\)区间内的逆序对数. 强制在线. 思路 参考:http://www.cnblogs.com/candy99/p/65795 ...

  5. 求逆序对数总结 & 归并排序

    用归并排序方式 最原始的方法的复杂度是O(n^2). 使用归并排序的方式,可以把复杂度降低到O(nlgn). 设A[1..n]是一个包含N个非负整数的数组.如果在i〈 j的情况下,有A〉A[j],则( ...

  6. 【Codeforces】CF 911 D. Inversion Counting(逆序对+思维)

    题目 传送门:QWQ 分析 思维要求比较高. 首先我们要把原图的逆序对q算出来. 这个树状数组或归并排序都ok(树状数组不用离散化好评) 那么翻转$[l,r]$中的数怎么做呢? 暴力过不了,我试过了. ...

  7. CodeForces - 987E Petr and Permutations (思维+逆序对)

    题意:初始有一个序列[1,2,...N],一次操作可以将任意两个位置的值互换,Petr做3*n次操作:Alxe做7*n+1次操作.给出最后生成的新序列,问是由谁操作得到的. 分析:一个序列的状态可以归 ...

  8. Codeforces 987 K预处理BFS 3n,7n+1随机结论题/不动点逆序对 X&Y=0连边DFS求连通块数目

    A /*Huyyt*/ #include<bits/stdc++.h> #define mem(a,b) memset(a,b,sizeof(a)) #define pb push_bac ...

  9. 归并求逆序数(逆序对数) && 线段树求逆序数

    Brainman Time Limit: 1000 MS Memory Limit: 30000 KB 64-bit integer IO format: %I64d , %I64u   Java c ...

随机推荐

  1. BurpSuite(二) proxy 模块

      Proxy代理模块作为BurpSuite的核心功能,拦截HTTP/S的代理服务器,作为一个在浏览器和目标应用程序之间的中间人,允许你拦截,查看,修改在两个方向上的原始数据流. Burp 代理允许你 ...

  2. ArcGISDynamicMapServiceLayer 和 ArcGISTiledMapServiceLayer 区别

    ArcGISDynamicMapServiceLayer(动态地图服务)通常用于实时显示经常变化的数据,支持控制单个图层可见性,可动态投影.但缺点是显示效果较差,整个服务出图较慢:ArcGISTile ...

  3. Selenium 2自动化测试实战20(操作cookie)

    一.操作cookie 有时候我们需要验证浏览器中cookie是否正确,因为基于真实cookie的测试是无法通过白盒和集成测试的.WebDriver提供了操作Cookie的相关方法,可以读取.添加和删除 ...

  4. Swift 发送邮件和附件

    public function send($filename, array $render = [],$subject = '审核通知') { // Create the Transport $tra ...

  5. Selenium+java自动化测试常用知识点

    一.元素的定位 1.通过ID定位元素: findElement(By.id(element)); 2.通过元素的名称定位元素: findElement(By.name(element)); 3.通过元 ...

  6. Shell编程、part4

    本节内容 1. shell函数 2. shell正则表达式 shell函数 shell中允许将一组命令集合或语句形成一段可用代码,这些代码块称为shell函数.给这段代码起个名字称为函数名,后续可以直 ...

  7. ubuntu16.04离线安装nvidia-docker2

    目前需要离线对ubuntu 进行封装docker环境 在熟悉docker环境过程中,有网络条件下,还处于懵逼状态 离线安装…… 大佬救救我 来了: 首先下载安装docker最新版 我的OS是Ubunt ...

  8. 换根dp特征总结

    Rt,大概总结一下吧(不时更新一小下 1.一般都没有指定根,刚开始随便选一个根(1号点工具人) 2.两次$dfs$,一次从工具人开始预处理一些东西,第二次(也是从工具人开始)换根. 3.多用于:只要确 ...

  9. 滚动翻页vue

    <template> <div class="home"> <div style="height:100%; width:100%;&quo ...

  10. 【VS开发】解决位图缩放失真

    当用以下函数加载一张位图时,当窗口发生重绘更改大小时,位图将失真: CBitmap bitmap;  bitmap.LoadBitmap(IDB_BITMAP2);  BITMAP bmp;  bit ...