Submission #1066690

#TimeUsernameProblemLanguageResultExecution timeMemory
1066690sleepntsheepAlternating Current (BOI18_alternating)C++17
13 / 100
6 ms600 KiB
#include <stdio.h>

int n, m, a[16], b[16];

int main() {
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; ++i) scanf("%d%d", a + i, b + i), --a[i], --b[i];
	for (int ii = 0; ii < (1 << m); ++ii) {
		for (int i = 0; i < n; ++i) {
			int c {};
			for (int j = 0; j < m; ++j) {
				int dir = (ii >> j) & 1;
				if (a[j] <= b[j]) {
					if (a[j] <= i && i <= b[j]) c |= 1 << dir;
				} else {
					if (i <= b[j] or i >= a[j]) c |= 1 << dir;
				}
			}
			if (c != 3) goto NX;
		}
		for (int j = 0; j < m; ++j) {
			putchar('0' + ((ii >> j) & 1));
		}
		return 0;
NX:;
	}
	puts("impossible");
	return 0;
}

Compilation message (stderr)

alternating.cpp: In function 'int main()':
alternating.cpp:6:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    6 |  scanf("%d%d", &n, &m);
      |  ~~~~~^~~~~~~~~~~~~~~~
alternating.cpp:7:35: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 |  for (int i = 0; i < m; ++i) scanf("%d%d", a + i, b + i), --a[i], --b[i];
      |                              ~~~~~^~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...