[luoguP1056] 排座椅(sort + 模拟)
2024-09-30 16:27:31
nc题,一直sort就过了
代码
#include <cstdio>
#include <iostream>
#include <algorithm>
#define N 2001
#define min(x, y) ((x) < (y) ? (x) : (y)) int n, m, k, l, d; struct node
{
int v, id;
}p1[N], p2[N]; inline int read()
{
int x = 0, f = 1;
char ch = getchar();
for(; !isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
for(; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + ch - '0';
return x * f;
} inline bool cmp(node x, node y)
{
return x.v > y.v;
} inline bool cmp1(node x, node y)
{
return x.id < y.id;
} int main()
{
int i, x1, x2, y1, y2;
n = read();
m = read();
k = read();
l = read();
d = read();
for(i = 1; i < n; i++) p1[i].id = i;
for(i = 1; i < m; i++) p2[i].id = i;
for(i = 1; i <= d; i++)
{
x1 = read();
y1 = read();
x2 = read();
y2 = read();
if(x1 ^ x2) p1[min(x1, x2)].v++;
if(y1 ^ y2) p2[min(y1, y2)].v++;
}
std::sort(p1 + 1, p1 + n, cmp);
std::sort(p1 + 1, p1 + k + 1, cmp1);
for(i = 1; i <= k; i++) printf("%d ", p1[i].id);
puts("");
std::sort(p2 + 1, p2 + m, cmp);
std::sort(p2 + 1, p2 + l + 1, cmp1);
for(i = 1; i <= l; i++) printf("%d ", p2[i].id);
puts("");
return 0;
}
最新文章
- 转:大神提出来的java服务器方面面试问题(当作自己的学习目标平时得多注意)
- [Oracle](不会的是三炮)把状态列表作为存储过程参数这件小事
- EF OnModelCreating
- AngularJS - 快速入门
- Jquery手册
- 【转】MYSQL入门学习之十:视图的基本操作
- 利用smarty call函数实现无限极分类
- Elasticsearch学习笔记
- C#学习笔记(三)
- lightoj 1300 边双联通分量+交叉染色求奇圈
- CLR via C# - 基础拾遗
- linux定时任务访问url
- 关于CSS格式与布局中的基础知识的简单操作
- Spring / Hibernate 应用性能调优
- SQL server SELECT 语句的基本结构
- oralce 11.2.0.4手动创建EM
- LeetCode: Largest Rectangle in Histogram 解题报告
- 页面 JavaScript 存在多个同名方法的调用分析
- Java EE之表达式语言EL(下)
- Android Studio 创建/打开项目时一直处于Building“project name”Gradle project info 的解决