include
using namespace std;
struct n {
string s;
};
int m, b[1010], h[1010], k = 1;
n a[1010];
int main() {
cin >> m;
for(int i=0;i> a[i].s;
}
for (int i = 0; i < m; i++) {
if (b[i] == 0) {
if (a[i].s == "XXL") {
h[i]=k;
int tot = 1;
for (int j = i; j < m; j++) {
if (b[j] == 0) {
if (a[j].s == "XXL" || a[j].s == "XL") {
if (b[j] == 0 && tot <= 5) {
b[j] = 1;
tot++;
h[j] = k;
}
}
}
}
}else if (a[i].s == "XL") {
h[i]=k;
int tot = 1;
for (int j = i; j < m; j++) {
if (b[j] == 0) {
if (a[j].s == "XL" || a[j].s == "L") {
if (b[j] == 0 && tot <= 5) {
b[j] = 1;
tot++;
h[j] = k;
}
}
}
}
} else if (a[i].s == "L") {
h[i]=k;
int tot = 1;
for (int j = i; j < m; j++) {
if (b[j] == 0) {
if (a[j].s == "L" || a[j].s == "M") {
if (b[j] == 0 && tot <= 5) {
b[j] = 1;
tot++;
h[j] = k;
}
}
}
}
} else if (a[i].s == "M") {
h[i]=k;
int tot = 1;
for (int j = i; j < m; j++) {
if (b[j] == 0) {
if (a[j].s == "M" || a[j].s == "S") {
if (b[j] == 0 && tot <= 5) {
b[j] = 1;
tot++;
h[j] = k;
}
}
}
}
} else if (a[i].s == "S") {
h[i]=k;
int tot = 1;
for (int j = i; j < m; j++) {
if (b[j] == 0) {
if (a[j].s == "S" || a[j].s == "XS") {
if (b[j] == 0 && tot <= 5) {
b[j] = 1;
tot++;
h[j] = k;
}
}
}
}
} else if (a[i].s == "XS") {
h[i]=k;
int tot = 1;
for (int j = i; j < m; j++) {
if (b[j] == 0) {
if (a[j].s == "XS" || a[j].s == "XXS") {
if (b[j] == 0 && tot <= 5) {
b[j] = 1;
tot++;
h[j] = k;
}
}
}
}
} else {
h[i]=k;
int tot = 1;
for (int j = i; j < m; j++) {
if (b[j] == 0) {
if (a[j].s == "XXS") {
if (b[j] == 0 && tot <= 5) {
b[j] = 1;
tot++;
h[j] = k;
}
}
}
}
}
k++;
}
} for (int i = 0; i < m; i++) { cout << h[i] << endl; } return 0; }
—— 本文来自火龙信奥(义乌睿码科技):义乌青少年信息学奥赛与编程教育平台,专注 CSP-J/S、NOIP、GESP 竞赛培训,线上线下融合教学,助力编程升学。网址:hlcoding.com