浙大PAT甲级-1006
2017-06-28 10:47
459 查看
比较简单
关键点:
-vector的用法(可参考http://www.cnblogs.com/wang7/archive/2012/04/27/2474138.html)#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main()
{
int m, i, firstin, lastout;
cin>>m;
vector<string> id, in, out;
i=m;
while(i--){
string a,b,c;
cin>>a>>b>>c;
id.push_back(a);
in.push_back(b);
out.push_back(c);
}
firstin=lastout=0;
for(i=1;i<m;i++){
if((in[firstin][0]>in[i][0])||
(in[firstin][0]==in[i][0]&&in[firstin][1]>in[i][1])||
(in[firstin][0]==in[i][0]&&in[firstin][1]==in[i][1]&&in[firstin][3]>in[i][3])||
(in[firstin][0]==in[i][0]&&in[firstin][1]==in[i][1]&&in[firstin][3]==in[i][3]&&in[firstin][4]>in[i][4])||
(in[firstin][0]==in[i][0]&&in[firstin][1]==in[i][1]&&in[firstin][3]==in[i][3]&&in[firstin][4]==in[i][4]&&in[firstin][6]>in[i][6])||
(in[firstin][0]==in[i][0]&&in[firstin][1]==in[i][1]&&in[firstin][3]==in[i][3]&&in[firstin][4]==in[i][4]&&in[firstin][6]==in[i][6]&&in[firstin][7]>in[i][7]))
firstin=i;
}
for(i=1;i<m;i++){
if((out[lastout][0]<out[i][0])||
(out[lastout][0]==out[i][0]&&out[lastout][1]<out[i][1])||
(out[lastout][0]==out[i][0]&&out[lastout][1]==out[i][1]&&out[lastout][3]<out[i][3])||
(out[lastout][0]==out[i][0]&&out[lastout][1]==out[i][1]&&out[lastout][3]==out[i][3]&&out[lastout][4]<out[i][4])||
(out[lastout][0]==out[i][0]&&out[lastout][1]==out[i][1]&&out[lastout][3]==out[i][3]&&out[lastout][4]==out[i][4]&&out[lastout][6]<out[i][6])||
(out[lastout][0]==out[i][0]&&out[lastout][1]==out[i][1]&&out[lastout][3]==out[i][3]&&out[lastout][4]==out[i][4]&&out[lastout][6]==out[i][6]&&out[lastout][7]<out[i][7]))
lastout=i;
}
cout<<id[firstin]<<" "<<id[lastout]<<endl;
return 0;
}
关键点:
-vector的用法(可参考http://www.cnblogs.com/wang7/archive/2012/04/27/2474138.html)#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main()
{
int m, i, firstin, lastout;
cin>>m;
vector<string> id, in, out;
i=m;
while(i--){
string a,b,c;
cin>>a>>b>>c;
id.push_back(a);
in.push_back(b);
out.push_back(c);
}
firstin=lastout=0;
for(i=1;i<m;i++){
if((in[firstin][0]>in[i][0])||
(in[firstin][0]==in[i][0]&&in[firstin][1]>in[i][1])||
(in[firstin][0]==in[i][0]&&in[firstin][1]==in[i][1]&&in[firstin][3]>in[i][3])||
(in[firstin][0]==in[i][0]&&in[firstin][1]==in[i][1]&&in[firstin][3]==in[i][3]&&in[firstin][4]>in[i][4])||
(in[firstin][0]==in[i][0]&&in[firstin][1]==in[i][1]&&in[firstin][3]==in[i][3]&&in[firstin][4]==in[i][4]&&in[firstin][6]>in[i][6])||
(in[firstin][0]==in[i][0]&&in[firstin][1]==in[i][1]&&in[firstin][3]==in[i][3]&&in[firstin][4]==in[i][4]&&in[firstin][6]==in[i][6]&&in[firstin][7]>in[i][7]))
firstin=i;
}
for(i=1;i<m;i++){
if((out[lastout][0]<out[i][0])||
(out[lastout][0]==out[i][0]&&out[lastout][1]<out[i][1])||
(out[lastout][0]==out[i][0]&&out[lastout][1]==out[i][1]&&out[lastout][3]<out[i][3])||
(out[lastout][0]==out[i][0]&&out[lastout][1]==out[i][1]&&out[lastout][3]==out[i][3]&&out[lastout][4]<out[i][4])||
(out[lastout][0]==out[i][0]&&out[lastout][1]==out[i][1]&&out[lastout][3]==out[i][3]&&out[lastout][4]==out[i][4]&&out[lastout][6]<out[i][6])||
(out[lastout][0]==out[i][0]&&out[lastout][1]==out[i][1]&&out[lastout][3]==out[i][3]&&out[lastout][4]==out[i][4]&&out[lastout][6]==out[i][6]&&out[lastout][7]<out[i][7]))
lastout=i;
}
cout<<id[firstin]<<" "<<id[lastout]<<endl;
return 0;
}
相关文章推荐
- 浙大PAT甲级1006
- 浙大pat | 浙大pat 牛客网甲级 1006 Cars on Campus (30)多区域覆盖题
- pat 甲级 1006
- [PAT甲级]1006. Sign In and Sign Out (25)(找出机房开门锁门的人)
- PAT甲级C语言.1006. 换个格式输出整数
- PAT 甲级 1006. Sign In and Sign Out (25)
- 1006. Sign In and Sign Out (25) PAT 甲级
- *浙大PAT甲级 1056
- *浙大PAT甲级 1072 最短路径dij
- 浙大PAT甲级 1090 广搜
- *浙大PAT甲级 1099层次遍历二叉查找树
- 浙大PAT甲级-1008
- PAT(甲级)1006. Sign In and Sign Out (25)
- 浙大PAT甲级-1015
- 浙大PAT甲级 1059
- 浙大PAT甲级 1112
- 【PAT甲级】1006. Sign In and Sign Out (25)
- PAT(甲级)1006. Sign In and Sign Out (25)
- 浙大PAT甲级 1026
- *浙大PAT甲级 1091 广搜