Submission #493265

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

int n, print;

void cmpswp(int i, int j) {
	if (i < n && j < n)
		printf("CMPSWP R%d R%d ", i + 1, j + 1), print = 1;
}

void flush() {
	if (print)
		printf("\n"), print = 0;
}

int main() {
	int n_, l_, l, l1, 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();
		}
	}
	return 0;
}

Compilation message

malnarisc.c: In function 'main':
malnarisc.c:25:20: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
   25 |    if ((i & 1 << l - 1) == 0)
      |                  ~~^~~
malnarisc.c:26:28: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
   26 |     cmpswp(i, i ^ (1 << l) - 1);
      |                   ~~~~~~~~~^~~
malnarisc.c:18:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |  scanf("%d", &n);
      |  ^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Expected integer, but "CMPSWP" found
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Expected integer, but "CMPSWP" found
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Expected integer, but "CMPSWP" found
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Expected integer, but "CMPSWP" found
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Expected integer, but "CMPSWP" found
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Expected integer, but "CMPSWP" found
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Expected integer, but "CMPSWP" found
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Expected integer, but "CMPSWP" found
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Expected integer, but "CMPSWP" found
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Expected integer, but "CMPSWP" found