pku1868.cpp
来自「这是ACM 方面的资料 是PKU的 北京大学的出来的」· C++ 代码 · 共 72 行
CPP
72 行
#include <stdio.h>
#include <algorithm>
using namespace std;
typedef struct
{
int x;
int id;
} Node;
const int size = 10001;
Node nd[size];
int N;
bool cp(Node a, Node b)
{
return a.x < b.x;
}
bool Tell(int a, int b, int c)
{
if (a > b && b > c)
{
return 1;
}
if (a < b && b < c)
{
return 1;
}
return 0;
}
bool Solve()
{
int i, j;
for (i = 0; i < N >> 1; i++)
{
for (j = 0; j + 2 * i < N; j++)
{
if (Tell(nd[j].id, nd[j + i].id, nd[j + 2 * i].id))
{
return 1;
}
}
}
return 0;
}
int main()
{
int i;
while (scanf("%d", &N) != -1 && N)
{
scanf(": ");
for (i = 0; i < N; i++)
{
scanf("%d", &nd[i].x);
nd[i].id = i;
}
sort(nd, nd + N, cp);
if (!Solve())
{
printf("yes\n");
}
else
{
printf("no\n");
}
}
return 0;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?