Submission #951714

# Submission time Handle Problem Language Result Execution time Memory
951714 2024-03-22T11:34:23 Z mocha Alternating Current (BOI18_alternating) C++14
0 / 100
20 ms 2652 KB
#include <bits/stdc++.h>
using namespace std;
const int mx = 1e5+5;

int n, m;

struct Edge {
	int fr, to;
	int id;
} e[mx];
bool ans[mx];

bool cmp( Edge a, Edge b ) {
	return a.fr == b.fr ? a.to < b.to : a.fr < b.fr;
}

int main() {
	cin.tie(0);ios::sync_with_stdio(0);

	cin >> n >> m;
	for (int i=0;i<m;i++) {
		cin >> e[i].fr >> e[i].to;
		e[i].id = i;
	}
	set<pair<int, int>> st;
	st.insert({1,0});
	st.insert({1,1});
	sort(e, e+m, cmp);	
	bool fl = 1;
	int now = 0;
	for (int i=0;i<n;i++) {
		auto [num, ty] = *st.begin();
		if (e[i].fr > num) { 
			fl = 0;
		} else {
			ans[e[i].id] = ty;
			st.erase(st.begin());
			st.insert({e[i].to+1, ty});
		}
	}
	for (auto [i,j]:st) fl = (fl and (i>n));
	if (fl) {
		for (int i=0;i<m;i++) {
			cout << ans[i];
		}
		cout << "\n";
	} else {
		cout << "impossible\n";
	}
}

Compilation message

alternating.cpp: In function 'int main()':
alternating.cpp:32:8: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   32 |   auto [num, ty] = *st.begin();
      |        ^
alternating.cpp:41:12: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   41 |  for (auto [i,j]:st) fl = (fl and (i>n));
      |            ^
alternating.cpp:30:6: warning: unused variable 'now' [-Wunused-variable]
   30 |  int now = 0;
      |      ^~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 0 ms 344 KB 'impossible' claimed, but there is a solution
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 0 ms 344 KB 'impossible' claimed, but there is a solution
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 0 ms 344 KB 'impossible' claimed, but there is a solution
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 20 ms 2652 KB Output is correct
2 Incorrect 4 ms 344 KB 'impossible' claimed, but there is a solution
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 0 ms 344 KB 'impossible' claimed, but there is a solution
3 Halted 0 ms 0 KB -