Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- typedef struct event {
- char person;
- int a[2];
- } event;
- int main(void) {
- int x;
- scanf("%i", &x);
- for (int i = 0, y = x; i < y; i++) {
- int rows;
- scanf("%i", &rows);
- int ptc;
- event arr[rows];
- for (int j = 0; j < rows; j++) {
- int cfrequency = 0;
- int cokfrequency = 0;
- int jfrequency = 0;
- int jokfrequency = 0;
- scanf("%i %i", &arr[j].a[0], &arr[j].a[1]);
- if (j == 0) {
- arr[0].person = 'C';
- }
- else if (j == 1) {
- arr[1].person = 'J';
- }
- else {
- ptc = j - 1;
- while (ptc >= 0) {
- if (arr[ptc].person == 'C') {
- cfrequency++;
- if (arr[j].a[0] >= arr[ptc].a[1] || arr[j].a[1] <= arr[ptc].a[0]) {
- cokfrequency++;
- }
- }
- else {
- jfrequency++;
- if (arr[j].a[0] >= arr[ptc].a[1] || arr[j].a[1] <= arr[ptc].a[0]) {
- jokfrequency++;
- }
- }
- ptc--;
- }
- if (cfrequency == cokfrequency) {
- arr[j].person = 'C';
- }
- else if (jfrequency == jokfrequency) {
- arr[j].person = 'J';
- }
- else {
- arr[0].person = 'A';
- ptc = 0;
- }
- }
- }
- if (arr[0].person == 'A')
- {
- printf("Case #%i: IMPOSSIBLE", i + 1);
- }
- else
- {
- printf("Case #%i: ", i + 1);
- for (int b = 0; b < rows; b++)
- {
- printf("%c", arr[b].person);
- }
- }
- printf("\n");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement