Submission #493266

# Submission time Handle Problem Language Result Execution time Memory
493266 2021-12-10T15:26:35 Z rainboy MalnaRISC (COI21_malnarisc) C
0 / 100
1 ms 204 KB
#include <stdio.h>

#define K	30
#define N	100

int ii[K][N], jj[K][N], nn[K], n, k;

void cmpswp(int i, int j) {
	if (i < n && j < n)
		ii[k][nn[k]] = i, jj[k][nn[k]] = j, nn[k]++;
}

void flush() {
	if (nn[k])
		k++;
}

int main() {
	int n_, l_, l, l1, h, i;

	scanf("%d", &n);
	l_ = 0;
	while (1 << l_ < n)
		l_++;
	n_ = 1 << l_;
	for (l = 1; l <= l_; l++) {
		for (i = 0; i < n_; i++)
			if ((i & 1 << l - 1) == 0)
				cmpswp(i, i ^ (1 << l) - 1);
		flush();
		for (l1 = l - 2; l1 >= 0; l1--) {
			for (i = 0; i < n_; i++)
				if ((i & 1 << l1) == 0)
					cmpswp(i, i ^ (1 << l1));
			flush();
		}
	}
	printf("%d\n", k);
	for (h = 0; h < k; h++) {
		for (i = 0; i < nn[h]; i++)
			printf("CMPSWP %d %d ", ii[h][i] + 1, jj[h][i] + 1);
		printf("\n");
	}
	return 0;
}

Compilation message

malnarisc.c: In function 'main':
malnarisc.c:28:20: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
   28 |    if ((i & 1 << l - 1) == 0)
      |                  ~~^~~
malnarisc.c:29:28: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
   29 |     cmpswp(i, i ^ (1 << l) - 1);
      |                   ~~~~~~~~~^~~
malnarisc.c:21:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |  scanf("%d", &n);
      |  ^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Token "1" doesn't correspond to pattern "R[0-9]{1,3}"
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Token "1" doesn't correspond to pattern "R[0-9]{1,3}"
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Token "1" doesn't correspond to pattern "R[0-9]{1,3}"
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Token "1" doesn't correspond to pattern "R[0-9]{1,3}"
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Token "1" doesn't correspond to pattern "R[0-9]{1,3}"
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Token "1" doesn't correspond to pattern "R[0-9]{1,3}"
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Token "1" doesn't correspond to pattern "R[0-9]{1,3}"
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Token "1" doesn't correspond to pattern "R[0-9]{1,3}"
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Token "1" doesn't correspond to pattern "R[0-9]{1,3}"
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Token "1" doesn't correspond to pattern "R[0-9]{1,3}"