Codeforces Round #323 (Div. 2) A 水
1 second
256 megabytes
standard input
standard output
City X consists of n vertical and n horizontal infinite roads, forming n × n intersections. Roads (both vertical and horizontal) are numbered from 1 to n, and the intersections are indicated by the numbers of the roads that form them.
Sand roads have long been recognized out of date, so the decision was made to asphalt them. To do this, a team of workers was hired and a schedule of work was made, according to which the intersections should be asphalted.
Road repairs are planned for n2 days. On the i-th day of the team arrives at the i-th intersection in the list and if none of the two roads that form the intersection were already asphalted they asphalt both roads. Otherwise, the team leaves the intersection, without doing anything with the roads.
According to the schedule of road works tell in which days at least one road will be asphalted.
The first line contains integer n (1 ≤ n ≤ 50) — the number of vertical and horizontal roads in the city.
Next n2 lines contain the order of intersections in the schedule. The i-th of them contains two numbers hi, vi (1 ≤ hi, vi ≤ n), separated by a space, and meaning that the intersection that goes i-th in the timetable is at the intersection of the hi-th horizontal and vi-th vertical roads. It is guaranteed that all the intersections in the timetable are distinct.
In the single line print the numbers of the days when road works will be in progress in ascending order. The days are numbered starting from 1.
2
1 1
1 2
2 1
2 2
1 4
1
1 1
1
In the sample the brigade acts like that:
- On the first day the brigade comes to the intersection of the 1-st horizontal and the 1-st vertical road. As none of them has been asphalted, the workers asphalt the 1-st vertical and the 1-st horizontal road;
- On the second day the brigade of the workers comes to the intersection of the 1-st horizontal and the 2-nd vertical road. The 2-nd vertical road hasn't been asphalted, but as the 1-st horizontal road has been asphalted on the first day, the workers leave and do not asphalt anything;
- On the third day the brigade of the workers come to the intersection of the 2-nd horizontal and the 1-st vertical road. The 2-nd horizontal road hasn't been asphalted but as the 1-st vertical road has been asphalted on the first day, the workers leave and do not asphalt anything;
- On the fourth day the brigade come to the intersection formed by the intersection of the 2-nd horizontal and 2-nd vertical road. As none of them has been asphalted, the workers asphalt the 2-nd vertical and the 2-nd horizontal road.
题意:一座城市被N(1 ≤ N ≤ 50)条水平路线和N条垂直路线分割出N*N个交叉口。有一个施工队将对城市路线进行施工N*N天。他们每天来到一个交叉口,如果这个交叉口对应的水平路线和垂直路线都没有被施工过,他们将对其施工,否则不施工。问施工队第几天施过工。
题解:数据很小,只需要开两个一维数组记录所有水平和垂直路线是否被施工过就行
#include<iostream>
#include<cstring>
#include<cstdio>
#include<queue>
#include<stack>
#include<vector>
#include<map>
#include<algorithm>
#define ll __int64
#define mod 1e9+7
#define PI acos(-1.0)
int n;
using namespace std;
int mp1[],mp2[];
int ans[];
int h,v;
int main()
{
scanf("%d",&n);
memset(mp1,,sizeof(mp1));
memset(mp2,,sizeof(mp2));
memset(ans,,sizeof(ans));
int jishu=;
for(int i=;i<=n*n;i++)
{
scanf("%d %d",&h,&v);
if(mp1[h]==&&mp2[v]==)
{
mp1[h]=;
mp2[v]=;
ans[jishu]=i;
jishu++;
}
}
cout<<ans[];
for(int i=;i<jishu;i++)
cout<<" "<<ans[i];
cout<<endl;
return ;
}
Codeforces Round #323 (Div. 2) A 水的更多相关文章
- Codeforces Round #365 (Div. 2) A 水
A. Mishka and Game time limit per test 1 second memory limit per test 256 megabytes input standard i ...
- Codeforces Round #323 (Div. 1) B. Once Again... 暴力
B. Once Again... Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/582/probl ...
- Codeforces Round #323 (Div. 2) C. GCD Table 暴力
C. GCD Table Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/583/problem/C ...
- 重复T次的LIS的dp Codeforces Round #323 (Div. 2) D
http://codeforces.com/contest/583/problem/D 原题:You are given an array of positive integers a1, a2, . ...
- Codeforces Round #404 (Div. 2)(A.水,暴力,B,排序,贪心)
A. Anton and Polyhedrons time limit per test:2 seconds memory limit per test:256 megabytes input:sta ...
- Codeforces Round #408 (Div. 2)(A.水,B,模拟)
A. Buying A House time limit per test:2 seconds memory limit per test:256 megabytes input:standard i ...
- Codeforces Round #323 (Div. 2) D. Once Again... 乱搞+LIS
D. Once Again... time limit per test 1 second memory limit per test 256 megabytes input standard inp ...
- Codeforces Round #323 (Div. 2) C. GCD Table map
题目链接:http://codeforces.com/contest/583/problem/C C. GCD Table time limit per test 2 seconds memory l ...
- Codeforces Round #394 (Div. 2)A水 B暴力 C暴力 D二分 E dfs
A. Dasha and Stairs time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
随机推荐
- ASP.NET各种技巧
1.动态添加文件框 前台页面关键部分: <script type="text/javascript"> //添加一个选项 function AddFileCtrol() ...
- 四面体ply格式文件图和数据对应关系分析
通过一个简单的文件来理解ply格式的文件是有所帮助的,我在网上找了一个四面体的ply文件,我通过meshlab打开看到的效果如下所示,我录制成gif文件,希望可以从不同角度展示出来: 同时我截图少许, ...
- WordPress免费清新响应式博客/杂志/图片三合一主题Nana
WordPress免费清新响应式博客/杂志/图片三合一主题Nana 一.主题安装须知 1.本主题必须安装文章点击统计插件:WP-PostViews,可以直接在后台插件→安装插件中直接搜索安装官方最新版 ...
- Eclipse 发布 JAR
明确要生成何种类型 jar 生成工具 jar,作为包被其他程序调用 具体步骤: 选中项目文件,点右键选择 Export ,JAR File 在弹出窗口选择,导出哪些文件,并且选择好 输出 JAR 的路 ...
- 通过rsync+inotify实现数据实时备份
rsync的优点与不足 与传统的cp,scp,tar,备份方式相比,rsync具有安全性高备份迅速支持增量备份的优点,可以满足对实时性要求不高的需求,例如定期备份文件服务器数据到远端服务器,但是,当数 ...
- django+xadmin在线教育平台(三)
通过留言版功能回顾django基础知识 将对于django目录结构,使用Django快速搭建可以提交的表单页面,models.py , urls.py, views.py. 从数据库中取出数据展示到h ...
- Linux时区修改
Linux修改时区的正确方法 CentOS和Ubuntu的时区文件是/etc/localtime,但是在CentOS7以后localtime以及变成了一个链接文件 [root@centos7 ~]# ...
- css3 横向拖拽
css: .tab{ list-style-type: none; display:-webkit-box; display:-webkit-flex; ...
- JZOJ 3509. 【NOIP2013模拟11.5B组】倒霉的小C
3509. [NOIP2013模拟11.5B组]倒霉的小C(beats) (File IO): input:beats.in output:beats.out Time Limits: 1000 ms ...
- 893E - Counting Arrays
E. Counting Arrays time limit per test 3 seconds memory limit per test 256 megabytes input standard ...