GCJ 2015 Round D
来源:互联网 发布:热血传奇mac客户端 编辑:程序博客网 时间:2024/05/16 15:55
Problem A. Cube IV
#include <iostream>using namespace std;int loc[1000001][2];int main(){ int T,S; //scanf("%d",&T); freopen("/Users/lyd/Downloads/A-large.in", "r", stdin); scanf("%d",&T); for (int k=1; k<=T; k++) { scanf("%d",&S); for (int i=0; i<S; i++) { for (int j=0; j<S; j++) { int map; scanf("%d",&map); loc[map][0]=i; loc[map][1]=j; } } int res=-1,step=-1; int prex=-100,prey=-100; int tempres=0; // int MAXS=1<<31; // printf("%d",MAXS); for (int i=S*S; i>=1; i--) { int x=loc[i][0]; int y=loc[i][1]; if (abs(x-prex)+abs(y-prey)==1) {//up,down,left,right tempres++; }else{ tempres=1; } if (tempres>=step) { step=tempres;//steps res=i;//start point } prex=x; prey=y; } printf("Case #%d: %d %d\n",k,res,step); } return 0;}
Problem B. GBus count
#include <cstdio>#include <iostream>using namespace std;int main(){ int T,N; freopen("/Users/lyd/Downloads/B-large.in", "r", stdin); scanf("%d",&T); for (int k=0; k<T ; k++) { scanf("%d",&N); int **p; p=new int *[N]; for (int i=0; i<N; i++) { p[i]=new int[2]; } for (int i=0; i<N; i++) { scanf("%d %d",&p[i][0],&p[i][1]); } int cN; scanf("%d",&cN); int *q=new int[cN]; for (int i=0; i<cN; i++) { q[i]=0; } int ci; for (int i=0; i<cN; i++) { scanf("%d",&ci); for (int j=0; j<N; j++) { if (p[j][0]<=ci&&p[j][1]>=ci) { q[i]++; } } } printf("Case #%d:",k+1); for (int i=0; i<cN; i++) { printf(" %d",q[i]); } printf("\n"); } return 0;}
Problem C. Sort a scrambled itinerary
#include <cstdio>#include <cstring>#include <iostream>using namespace std;int findArr(string str,string s[],int N){ for (int i=0; i<N; i++) { if (str==s[i]) { return i; } } return -1;}int main(){ int T,N; freopen("/Users/lyd/Downloads/C-large.in", "r", stdin); scanf("%d",&T); for (int k=0; k<T ; k++) { scanf("%d",&N); string *l; string *r; l=new string [N]; r=new string [N]; for (int i=0; i<N; i++) { cin>>l[i]; cin>>r[i]; } string st; string ed; int si=0; // int ei=0; //find the start point for (int i=0; i<N; i++) { //cout<<l[i]<<" "<<r[i]<<endl; if (findArr(l[i], r,N)==-1) { st=l[i]; si=i; } } /* //find the end point for (int i=0; i<N; i++) { if (findArr(r[i], l,N)==-1) { ed=r[i]; ei=i; } }*/ cout<<"Case #"<<k+1<<":"; for (int i=0; i<N; i++) { int t=findArr(st, l,N); string ed=r[t]; cout<<" "<<st<<"-"<<ed; st=ed; si=t; } cout<<endl; //cout<<" "<<st<<"-"<<ed<<endl; } return 0;}
0 0
- GCJ 2015 Round D
- gcj Round 1A 2015 Mushroom Monster
- gcj Round 1A 2015 Haircut
- 【gcj】2014 Round 3
- 【gcj】2013 round 2
- GCJ Qualification Round 2017
- 2014 GCJ Round 1A
- 2014 GCJ Round 1C
- 【gcj】2012 round 3 待填坑
- 【gcj】2012 round 2 待填坑
- GCJ Round 1A 2016
- GCJ Round 1B 2016
- GCJ Round 1A 2016 C.BFFS
- GCJ Round 1C 2016 题解
- GCJ Round 1A 2017 题解
- GCJ Qualification Round 2017 题解(部分)
- GCJ 2015 1A
- GCJ
- 138 顺时针打印矩阵
- 心好烦
- 双层桶-中位数求解
- 树的基本概念及性质
- 第三章 字符设备驱动程序——note
- GCJ 2015 Round D
- c\c++ 头文件的作用
- 约瑟夫环
- C#字体对话框
- 姚博文 来自2025年的大佬回忆:辞掉20万年薪,闯入互联网
- 140 打印出所有不同的排列 4不能在第三位,3与5不能相连
- bitset的使用
- 彻底铲除kindle文件
- JSP Servlet学习笔记