辣鸡CF 毁我青春
ABC三题都很SB,但需要大讨论之术或者代码写起来容易出错
D题一个一眼题,但写起来神烦,最终还卡了我数组大小
E我没看
最后C题惨遭FST,D后来改了改数组大小就过了,E还是没看
总结:不会写代码了
说白了还是人弱……
跪膜没FST并且rank44并且rating涨了二百多的yzy
掉了六十多rating,竟然这么少 不科学
A
题意:给一个排列,要求必须交换一次使得1和n的位置离得最远。
SB题,要特判一下奇怪的东西……代码写的丑
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<stack>
using namespace std;
typedef long long LL;
const int SZ = 200010;
const int INF = 1000000010;
int read()
{
int n = 0;
char a = getchar();
bool flag = 0;
while(a > '9' || a < '0') { if(a == '-') flag = 1; a = getchar(); }
while(a >= '0' && a <= '9') { n = n * 10 + a - '0'; a = getchar(); }
if(flag) n = -n;
return n;
}
int num[SZ];
int main()
{
int n = read();
int pos1,pos2;
for(int i = 1;i <= n;i ++)
{
num[i] = read();
if(num[i] == 1) pos1 = i;
if(num[i] == n) pos2 = i;
}
if(n == 1)
{
printf("0"); return 0;
}
if(n == 2)
{
printf("1"); return 0;
}
if(((pos1 == 1 && pos2 == n) || (pos1 == n || pos2 == 1)))
{
printf("%d",n - 1);
return 0;
}
printf("%d\n",max(max(abs(n - pos1),abs(1 - pos1)),max(abs(n - pos2),abs(1 - pos2))));
return 0;
}
B
题意:给n行杯子,构成金字塔形,其中第i行i个杯子。每分钟往顶层的杯子灌一个杯子的量的水,问n排杯子在t时刻后有多少个杯子是满的。
n<=10,0<=t<=10000
我竟然画了半天杨辉三角,最后还是写的模拟……这告诉我们不需要去想一些高端的算法只要能过就行了……
还有t=0的情况……
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
typedef long long LL;
const int SZ = 200010;
const int INF = 1000000010;
int read()
{
int n = 0;
char a = getchar();
bool flag = 0;