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. Linux 下 *.tar.gz 文件解压缩命令及错误处理

    1.压缩命令: 命令格式: tar -zcvf 压缩文件名 .tar.gz 被压缩文件名 可先切换到当前目录下,压缩文件名和被压缩文件名都可加入路径. 2.解压缩命令: 命令格式: tar -zxvf ...

  2. 自定义View饼状图的绘制

    package com.loaderman.customviewdemo; import android.content.Context; import android.graphics.Canvas ...

  3. windows命令行查看&生成项目树

    项目写好以后,想要查看项目结构或生成结构树便于后面查看,可以: 1.进入项目所在目录 2.输入tree,回车后显示项目 3.在项目根目录下保存生成的结构树 输入tree > list.txt命令

  4. Python学习之表的数据类型

    数据类型 数值类型 类型 大小 范围(有符号) 范围(无符号)unsigned约束 用途 TINYINT 1 字节 (-128,127) (0,255) 小整数值 SMALLINT 2 字节 (-32 ...

  5. 平衡树(fhq无旋treap)

    fhq板子(代码正确且风格易懂) 洛谷P3369 #include<iostream> #include<cstring> #include<cstdio> #in ...

  6. 事务与Mysql隔离级别

    事务 定义: 比如ABCD四个业务,作为一个事务,他们要么一起都执行完毕,要么都不执行.(只要有一个不成功,那么所有的都不可以成功) 四个特性 ACID 原子性(Atomicity) 整个事务中的所有 ...

  7. 【VS开发】循序渐进学习使用WINPCAP(一)

    winpcap教程 中文教程 http://www.ferrisxu.com/WinPcap/html/index.html 除此之外, WinPcap · Developer Resources下载 ...

  8. Adobe出品(支持IOS,android,web调用)免费插件编辑图片

    <head runat="server"><meta http-equiv="Content-Type" content="text ...

  9. python关键字以及含义,用法

    Python常用的关键字   1.and , or and , or 为逻辑关系用语,Python具有短路逻辑,False and 返回 False 不执行后面的语句, True or 直接返回Tru ...

  10. Hbase的几个关键问题(转自log.csdn.net/javastart/article/details/43772575)

    什么是HBase?何时用HBase?与Hive.Pig的区别?HBase的结构为何HBase速度很快?HBase常用的操作有哪些?HBase的一些配置和监控 什么是HBase? HBase,是Hado ...