Submission #426655

# Submission time Handle Problem Language Result Execution time Memory
426655 2021-06-14T08:46:06 Z KalasLavas RMQ (NOI17_rmq) C++14
0 / 100
1 ms 332 KB
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma,sse,sse2")
#include <bits/stdc++.h>
using namespace std;

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());
//#undef LOCALKL
#define IO \
ios_base::sync_with_stdio(0);(cin).tie(0);(cout).tie(0)
#define y1 y1_
#define prev prev_
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define eb emplace_back
#define F first
#define S second
#ifdef LOCALKL
// #define cerr cerr<<"\33[1;32m"
// #define cout cout<<"\33[0m"
#else
#ifndef OO
#define endl '\n'
#define cerr if(1){}else cerr
#endif
#endif
#define OK cout<<"OK\n"<<endl;
#define setpre(k) fixed<<setprecision(k)
#define mmset(k,y) memset(k,y,sizeof(k))
#define sz(x) ((int)(x).size())
using pii = pair<int,int>;
using pll = pair<long long,long long>;
using ull = unsigned long long;
using intt = long long;
using ll = long long;
using ld = long double;

const ll m9 = 998244353;
const ll m7 = 1000000007;
const ll m18 = 1000000000000000000;
const ll i127 = 2139062143;
const ll l127 = 9187201950435737471;

struct query
{
	int l, r, x;
	bool operator<(query b)
	{
		if(x==b.x)
		{
			if(l==b.l) return r<b.r;
			return l<b.l;
		}
		return x<b.x;
	}
};

int n,q, ans[100001];
query a[100001];
bool c[100001];
int main()
{
    IO;
    cin>>n>>q;
    for(int i=0;i<q;i++) cin>>a[i].l>>a[i].r>>a[i].x;
	sort(a, a+q);
	for(int i=0;i<n;i++)
	{
		memset(c,0,n);
		for(int j=0;j<n;j++) c[j]=ans[j];
		for(int j=0;j<q;j++)
			if(i<a[j].x)
			{
				for(int k=a[j].l;k<=a[j].r;k++) c[k]=1;
			}
			else if(i==a[j].x)
			{
				for(int k=0;k<a[j].l;k++) c[k]=1;
				for(int k=a[j].r+1;k<n;k++) c[k]=1;
			}
		int pos=-1;
		for(int j=0;j<n;j++)
			if(!c[j]) pos=j;
		if(pos==-1) return cout<<-1, 0;
		ans[pos]=i+1;
	}
	for(int i=0;i<n;i++) cout<<ans[i]-1<<' ';
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Incorrect 1 ms 204 KB Unexpected end of file - int32 expected
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Incorrect 1 ms 204 KB Unexpected end of file - int32 expected
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Incorrect 1 ms 204 KB Unexpected end of file - int32 expected
7 Halted 0 ms 0 KB -