给素材分类,若作品1中有素材1和素材2,则认为素材1和素材2为一类,若作品2中有素材2和素材3,那么此后认为素材1、2、3为一类

输入:第一行为作品数n,此后n行中每行第一位为该作品中的素材总数m,此后m个数字为素材名(int型)

输出:素材的分类,并且每一类素材,类内顺序由小到大,类外顺序按照类内最小值由小到大排序输出

示例:

1
2
3
4
5
6
7
8
9
10
11
输入:
4
2 1 3
3 0 5 6
3 2 3 4
1 7

输出:
0 5 6
1 2 3 4
7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#include <iostream>
#include<vector>
#include<string>

using namespace std;

int main()
{
vector<vector<int>> resV;
int num;
cin >> num;
for (int i = 0; i < num; i++)
{
int cat;
cin >> cat;
//存放该作品内所有素材的vector
vector<int> tempV;
for (int j = 0; j < cat; j++)
{
int mem;
cin >> mem;
tempV.push_back(mem);
//cout << tempV[j];
}
//能否找到已存在的类,能找到就将tempV添加进去
int label = 0;
for (int k = 0; k < tempV.size(); k++)
{
for (int out = 0; out < resV.size(); out++)
{
int flag = 0;
for (int in = 0; in < resV[out].size(); in++)
{

if (tempV[k] == resV[out][in])
{
label = 1;
flag = 1;
for (int copy = 0; copy < tempV.size(); copy++)
{
//检查重复素材,重复的素材不添加,只在已有的分类中添加还未加入的素材
if (find(resV[out].begin(), resV[out].end(), tempV[copy]) == resV[out].end())
resV[out].push_back(tempV[copy]);
}
break;
}
}
//不用再继续遍历后面的子vector了,添加进一个分类中就一定不会添加进另外一个分类
if (flag == 1)
break;
}
}
//是新的素材分类
if (label == 0)
{
resV.push_back(tempV);
}
}
//子vector按最小元素排序
sort(resV.begin(), resV.end());
for (int i = 0; i < resV.size(); i++)
{
//子vector内部排序
sort(resV[i].begin(), resV[i].end());
for (int j = 0; j < resV[i].size(); j++)
cout << resV[i][j] << " ";
cout << endl;
}
return 0;
}

计算给出时间和格林尼治时间之间的秒数,格式:YYYY/MM/DD hh:mm:ss

需要考虑平年和闰年

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#include <iostream>
#include<vector>
#include<string>

using namespace std;

int main()
{
string date, time;
cin >> date >> time;
long long int year, month, day;
//切分成子字符串之后再转整型,赋给年月日时分秒
//atoi()的参数是 const char* ,因此对于一个字符串str我们必须调用c_str()的方法把这个string转换成const char*类型的
//substr(pos, num)两个参数是从起始位置和pos开始取的字符个数,而不是起始位置和末尾位置
year = atoi(date.substr(0, 4).c_str());
month = atoi(date.substr(5, 2).c_str());
day = atoi(date.substr(8, 2).c_str());
long long int hour, minute, second;
hour = atoi(time.substr(0, 2).c_str());
minute = atoi(time.substr(3, 2).c_str());
second = atoi(time.substr(6, 2).c_str());
long long int time1 = 0;
//cout << hour << " " << minute << " " << second;
cout << year << " " << month << " " << day << endl;
//cout << second << to_string(minute * 60) << to_string(hour * 3600) << second + minute * 60 + hour * 3600;
//给出的一天内的时间计算
time1 = second + minute * 60 + hour * 3600;
long long int time2 = 0;
long long int run = 0;
for (int i = 1970; i < year; i++)
{
if ((i % 4 == 0 && i % 100 != 0) || i % 400 == 0)
run++;
}
cout << run << endl;
//给出的年月日的时间计算
time2 += run * 366 * 3600 * 24 + (year - 1970 - run) * 365 * 3600 * 24;
cout << time2 << endl;
long long int temp = 0;
//最后一年单独计算,因为最后一年未满整一年
//最后一年是闰年还是平年
if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0)
temp = 29;
else
temp = 28;
//最后一年除掉最后一个月的时间,因为最后一个月未满整一个月
switch (month)
{
case 01:
time2 += 0;
break;
case 02:
time2 += 31 * 3600 * 24;
break;
case 03:
time2 += (31 + temp) * 3600 * 24;
break;
case 04:
time2 += (62 + temp) * 3600 * 24;
break;
case 05:
time2 += (92 + temp) * 3600 * 24;
break;
case 06:
time2 += (123 + temp) * 3600 * 24;
break;
case 07:
time2 += (153 + temp) * 3600 * 24;
break;
//8和9特殊,编译器在识别08和09时不会自动转换成8和9,而是提示错误的八进制数
case 8:
time2 += (184 + temp) * 3600 * 24;
break;
case 9:
time2 += (215 + temp) * 3600 * 24;
break;
case 10:
time2 += (245 + temp) * 3600 * 24;
break;
case 11:
time2 += (276 + temp) * 3600 * 24;
break;
case 12:
time2 += (306 + temp) * 3600 * 24;
break;
}
//cout << time2 << endl;
time2 += (day - 1) * 24 * 3600;
//整的年月日的时间计算加上最后一日内的时分秒时间计算
long long int res = time1 + time2;
cout << res << endl;
return 0;
//1970/02/01 00:00:00
//2716/02/02 00:00:00
}