답안 #338044

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
338044 2020-12-22T10:57:29 Z Nimbostratus Restore Array (RMI19_restore) C++17
0 / 100
3 ms 492 KB
#include <bits/stdc++.h>
#define mt make_tuple
using namespace std;
typedef long long ll;
const ll INF = 1e15;
int N,M;
string ans;
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=0;i<N;i++) ans += '2';
	q.resize(M);
	for(int i=0;i<M;i++)
	{
		int l,r,k,v;
		cin >> l >> r >> k >> v;
		q[i] = mt(l,r,k,v);
	}
	for(int i=0;i<M;i++)
	{
		int l,r,k,v;
		tie(l,r,k,v) = q[i];
		if(v == 1)
			for(int i=l;i<=r;i++)
				ans[i] = '1';
	}
	for(int i=0;i<M;i++)
	{
		int l,r,k,v;
		tie(l,r,k,v) = q[i];
		if(v == 0)
		{
			bool flag = 0;
			for(int i=l;i<=r;i++)
			{
				if(ans[i] == '2')
				{
					ans[i] = '0' , flag = 1;
					break;
				}  
			}
			if(!flag)
			{
				cout << -1 << endl;
				return 0;
			}
		}
	}
	for(int i=0;i<ans.size();i++)
		cout << (ans[i] == '2' ? '1' : ans[i]) << " ";
}

Compilation message

restore.cpp: In function 'int32_t main()':
restore.cpp:56:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |  for(int i=0;i<ans.size();i++)
      |              ~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 492 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 492 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -