2022-10-08 09:33:48 +08:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
2022-10-11 16:57:12 +08:00
|
|
|
typedef struct listNode {
|
|
|
|
int id;
|
|
|
|
struct listNode *next;
|
|
|
|
} listNode;
|
2022-10-08 09:33:48 +08:00
|
|
|
|
2022-10-11 16:57:12 +08:00
|
|
|
listNode *appendNode(int id, listNode *head) {
|
|
|
|
listNode *new = malloc(sizeof(listNode));
|
|
|
|
new->id = id;
|
|
|
|
new->next = NULL;
|
|
|
|
|
|
|
|
head->next = new;
|
2022-10-08 09:33:48 +08:00
|
|
|
return new;
|
|
|
|
}
|
|
|
|
|
2022-10-11 16:57:12 +08:00
|
|
|
int main(void) {
|
|
|
|
listNode* head = malloc(sizeof(listNode));
|
|
|
|
listNode* ptr = head;
|
2022-10-08 09:33:48 +08:00
|
|
|
|
2022-10-11 16:57:12 +08:00
|
|
|
int size = 0;
|
|
|
|
int buf;
|
|
|
|
while ((scanf("%d,", & buf) != EOF)) {
|
|
|
|
ptr = appendNode(buf, ptr);
|
|
|
|
size++;
|
|
|
|
}
|
2022-10-08 09:33:48 +08:00
|
|
|
|
2022-10-11 16:57:12 +08:00
|
|
|
if (size <= 1) {
|
|
|
|
printf("Yes");
|
|
|
|
return 0;
|
|
|
|
}
|
2022-10-08 09:33:48 +08:00
|
|
|
|
2022-10-11 16:57:12 +08:00
|
|
|
int ans[size];
|
2022-10-08 09:33:48 +08:00
|
|
|
|
2022-10-11 16:57:12 +08:00
|
|
|
head = head->next;
|
|
|
|
for (int i = 0; i < size; i ++) {
|
|
|
|
ans[i] = head->id;
|
|
|
|
head = head->next;
|
|
|
|
}
|
2022-10-08 09:33:48 +08:00
|
|
|
|
2022-10-11 16:57:12 +08:00
|
|
|
int isCentral = 1;
|
|
|
|
for (int i = 0, end = size / 2; i < end; i++) {
|
|
|
|
if (ans[i] != ans[size - i - 1]) {
|
|
|
|
isCentral = 0;
|
2022-10-08 09:33:48 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-10-11 16:57:12 +08:00
|
|
|
if (isCentral == 1) {
|
2022-10-08 09:33:48 +08:00
|
|
|
printf("Yes");
|
|
|
|
} else {
|
|
|
|
printf("No");
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|