답안 #338040

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
338040 2020-12-22T10:20:50 Z Nimbostratus Restore Array (RMI19_restore) C++17
7 / 100
206 ms 748 KB
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const ll INF = 1e15;
int N,M;
vector<tuple<int,int,int,int>> q;

int32_t main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	//freopen("in","r",stdin);
	//freopen("out","w",stdout);
	cin >> N >> M;
	for(int i=1;i<=M;i++)
	{
		int l,r,k,v;
		cin >> l >> r >> k >> v;
		q.push_back(make_tuple(l,r,k,v));
	}
	for(int i=0;i<(1<<N);i++)
	{
		string cur;
		for(int k=0;k<N;k++)
			cur = char('0' + !!(i&(1<<k))) + cur;
		int pre[cur.size()+5];
		pre[0] = (cur[0] - '0');
		for(int i=1;i<cur.size();i++)
			pre[i] = pre[i-1] + (cur[i] - '0');
		bool flag = 1;
		for(int i=0;i<M and flag;i++)
		{
			int l,r,k,v;
			tie(l,r,k,v) = q[i];
			//cout << l << " " << r << " " << k << " " << v << endl;
			int onecnt = pre[r] - (l == 0 ? 0 : pre[l-1]);
			if(v == 0)
				flag = flag and ((r-l+1)-onecnt >= k); 
			else
				flag = flag and ((r-l+1)-onecnt < k);
		}
		if(flag)
		{
			for(int i=0;i<cur.size();i++)
				cout << int(cur[i]-'0') << " ";
			return 0;
		}
	}
	cout << -1 << endl;
}

Compilation message

restore.cpp: In function 'int32_t main()':
restore.cpp:30:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |   for(int i=1;i<cur.size();i++)
      |               ~^~~~~~~~~~~
restore.cpp:46:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |    for(int i=0;i<cur.size();i++)
      |                ~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 13 ms 364 KB Output is correct
4 Correct 107 ms 364 KB Output is correct
5 Correct 206 ms 492 KB Output is correct
6 Correct 92 ms 364 KB Output is correct
7 Correct 15 ms 364 KB Output is correct
8 Correct 25 ms 364 KB Output is correct
9 Correct 109 ms 492 KB Output is correct
10 Correct 45 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 748 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 748 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 13 ms 364 KB Output is correct
4 Correct 107 ms 364 KB Output is correct
5 Correct 206 ms 492 KB Output is correct
6 Correct 92 ms 364 KB Output is correct
7 Correct 15 ms 364 KB Output is correct
8 Correct 25 ms 364 KB Output is correct
9 Correct 109 ms 492 KB Output is correct
10 Correct 45 ms 364 KB Output is correct
11 Incorrect 4 ms 748 KB Output isn't correct
12 Halted 0 ms 0 KB -