import java.util.*;class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while (sc.hasNext()) { int N = sc.nextInt(); MultiValueMap<String, String> stringMultiValueMap = new LinkedMultiValueMap<>(); while (N-- > 0) { String id = sc.next(); String time = sc.next(); stringMultiValueMap.add(id, time); } Set<String> keySet = stringMultiValueMap.keySet(); for (String key : keySet) { List<String> values = stringMultiValueMap.getValues(key); if (values.size() < 6) continue; ArrayList<Integer> total_times = new ArrayList<>(); for (String value : values) { int h = Integer.parseInt(value.substring(0, 2)); int d = Integer.parseInt(value.substring(3, 5)); int s = Integer.parseInt(value.substring(6, 8)); int total_time = h * 3600 + d * 60 + s; total_times.add(total_time); } Collections.sort(total_times); if (check(total_times)) System.out.println(key); } } } private static boolean check(ArrayList<Integer> list) { for (int i = 0; i <= list.size() - 6; i++) { for (int j = i + 1; j < i + 6; j++) { if (Math.abs(list.get(i) - list.get(j)) >= 3600) return false; } } return true; }}interface MultiValueMap<K, V> { void add(K key, V value); void add(K key, List<V> values); void set(K key, V value); void set(K key, List<V> values); void set(Map<K, List<V>> values); List<V> remove(K key); void clear(); Set<K> keySet(); List<V> values(); V getValue(K key, int index); List<V> getValues(K key); int size(); boolean isEmpty(); boolean containsKey(K key);}class LinkedMultiValueMap<K, V> implements MultiValueMap<K, V> { protected Map<K, List<V>> mSource = new LinkedHashMap<K, List<V>>(); public LinkedMultiValueMap() { } @Override public void add(K key, V value) { if (key != null) { if (!mSource.containsKey(key)) mSource.put(key, new ArrayList<V>(2)); mSource.get(key).add(value); } } @Override public void add(K key, List<V> values) { for (V value : values) { add(key, value); } } @Override public void set(K key, V value) { mSource.remove(key); add(key, value); } @Override public void set(K key, List<V> values) { mSource.remove(key); add(key, values); } @Override public void set(Map<K, List<V>> map) { mSource.clear(); mSource.putAll(map); } @Override public List<V> remove(K key) { return mSource.remove(key); } @Override public void clear() { mSource.clear(); } @Override public Set<K> keySet() { return mSource.keySet(); } @Override public List<V> values() { List<V> allValues = new ArrayList<V>(); Set<K> keySet = mSource.keySet(); for (K key : keySet) { allValues.addAll(mSource.get(key)); } return allValues; } @Override public List<V> getValues(K key) { return mSource.get(key); } @Override public V getValue(K key, int in
阅读全部
|
java小白兔
贴于 2018年11月7日 16:57
hide
bbsi
import java.util.*;class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while (sc.hasNext()) { int N = sc.nextInt(); MultiValueMap<String, String> stringMultiValueMap = new LinkedMultiValueMap<>(); while (N-- > 0) { String id = sc.next(); String time = sc.next(); stringMultiValueMap.add(id, time); } Set<String> keySet = stringMultiValueMap.keySet(); for (String key : keySet) { List<String> values = stringMultiValueMap.getValues(key); if (values.size() < 6) continue; ArrayList<Integer> total_times = new ArrayList<>(); for (String value : values) { int h = Integer.parseInt(value.substring(0, 2)); int d = Integer.parseInt(value.substring(3, 5)); int s = Integer.parseInt(value.substring(6, 8)); int total_time = h * 3600 + d * 60 + s; total_times.add(total_time); } Collections.sort(total_times); if (check(total_times)) System.out.println(key); } } } private static boolean check(ArrayList<Integer> list) { for (int i = 0; i <= list.size() - 6; i++) { for (int j = i + 1; j < i + 6; j++) { if (Math.abs(list.get(i) - list.get(j)) >= 3600) return false; } } return true; }}interface MultiValueMap<K, V> { void add(K key, V value); void add(K key, List<V> values); void set(K key, V value); void set(K key, List<V> values); void set(Map<K, List<V>> values); List<V> remove(K key); void clear(); Set<K> keySet(); List<V> values(); V getValue(K key, int index); List<V> getValues(K key); int size(); boolean isEmpty(); boolean containsKey(K key);}class LinkedMultiValueMap<K, V> implements MultiValueMap<K, V> { protected Map<K, List<V>> mSource = new LinkedHashMap<K, List<V>>(); public LinkedMultiValueMap() { } @Override public void add(K key, V value) { if (key != null) { if (!mSource.containsKey(key)) mSource.put(key, new ArrayList<V>(2)); mSource.get(key).add(value); } } @Override public void add(K key, List<V> values) { for (V value : values) { add(key, value); } } @Override public void set(K key, V value) { mSource.remove(key); add(key, value); } @Override public void set(K key, List<V> values) { mSource.remove(key); add(key, values); } @Override public void set(Map<K, List<V>> map) { mSource.clear(); mSource.putAll(map); } @Override public List<V> remove(K key) { return mSource.remove(key); } @Override public void clear() { mSource.clear(); } @Override public Set<K> keySet() { return mSource.keySet(); } @Override public List<V> values() { List<V> allValues = new ArrayList<V>(); Set<K> keySet = mSource.keySet(); for (K key : keySet) { allValues.addAll(mSource.get(key)); } return allValues; } @Override public List<V> getValues(K key) { return mSource.get(key); } @Override public V getValue(K key, int in
阅读全部
|
java小白兔
贴于 2018年11月7日 16:57
hide
bbsi
// rr.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include<stdio.h>
int sum1(int n)
{
if(n==1)return 1;
return sum1(n-1)*n;
}
int sum2(int n)
......................
阅读全部
|
Mror
贴于 2018年11月5日 22:33
hide
bbsi
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
float rabbit;
float tortoise;
void *runner_rabbit(void *param);
void *runner_tortoise(void *param);
int main(int argc, char *argv[])
{
srand(time(NULL));
......................
阅读全部
|
mimijilu
贴于 2018年11月1日 14:27
show
bbsi
#include <stdio.h>
main()
{
float height,faHeight,moHeight;
char sex,sports,diet;
printf("请输入被测人信息:性别,是否喜爱运动,是否饮食良好:");
scanf("%f,%f,%f,%c,%c,%c",&height,&faHeight,&moHeight,&sex,&sports,&diet);
if(sex=='F' && sports=='Y' && diet=='Y')
{
height=((faHeight*0.923+moHeight)/2)*(1+0.02+0.015);
printf("%f",height);
}
......................
阅读全部
|
周啦啦
贴于 2018年10月31日 19:25
hide
bbsi
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
using namespace std;
struct Bnode
{
char data;
Bnode *lch;
Bnode *rch;
};
typedef Bnode* Btree;
......................
阅读全部
|
mimijilu
贴于 2018年10月30日 13:22
show
bbsi
public class Lei {
String name;
}
class Lei1{
public static void main(String[] args) {
Lei S1=new Lei();
System.out.println(S1.name);
}
} 本来是应该输出空值Null的,但是我的就是不能老报错,求大神指导
阅读全部
|
陈无
贴于 2018年10月25日 22:55
hide
bbsi
#include<iostream>
#include<cstdlib>
using namespace std;
int getint(int a,int b){
if(a==0)return b;
if(b==0)return a;
cout<<a<<endl;
return getint(a-1,b-1);
}
int ungetint(int a){
if(a<=0)return 0;
......................
阅读全部
|
MC189
贴于 2018年10月21日 16:41
hide
bbsi
public class Yuman{
public static void mian(String[] args){
int x=5,y=10;
if (x<y);
{
System.out.println("正确");
}
else;
{
Sytem.out.println("错误");
}
......................
阅读全部
|
yuyiman330
贴于 2018年10月17日 17:36
hide
bbsi