제출 #128223

#제출 시각아이디문제언어결과실행 시간메모리
128223claudyBridges (APIO19_bridges)C++14
0 / 100
3004 ms6244 KiB
//# pragma GCC optimize("Ofast,no-stack-protector")
//# pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
# pragma GCC optimize("Ofast")
# pragma GCC optimization ("unroll-loops")
# include "bits/stdc++.h"
std::pair<int,int> DR[] = {{-1,0},{0,1},{1,0},{0,-1},{-1,1},{-1,-1},{1,1},{1,-1}};
# define ll long long
# define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
# define rc(s) return cout << s,0
# define rcg(s) cout << s;exit(0)
# define _ ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
# define db(x) cerr << #x << " = " << x << '\n'
# define pb push_back
# define mp make_pair
# define all(s) s.begin(),s.end()
# define sz(x) (int)((x).size())
//# define int ll
using namespace std;

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# define LOCAL
# define sim template < class c
# define ris return * this
# define dor > debug & operator <<
# define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
*this << "[";
for (auto it = d.b; it != d.e; ++it)
*this << ", " + 2 * (it == d.b) << *it;
ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define show(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
int gcd(int a, int b)
{
if(b) return gcd(b,a%b);
return a;
}mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

const int L = 230;
int pos,f[1 << 17],mn[1 << 17],n,m,a[1 << 17],b[1 << 17],c[1 << 17],q;

void upd(int pos,int val)
{
	pos--;
	f[pos] = val;
	int block = pos / L;
	mn[block] = val;
	for(int i = block * L;i < (block + 1) * L;i++) mn[block] = min(mn[block],f[i]);
}

int qry(int pos,int val)
{
	pos--;
	int block = pos / L;
	bool B = 1;
	int l,r;
	for(int i = pos;i < (block + 1) * L;i++)
	{
		if(f[i] < val)
		{
			r = i - 1;
			B = 0;
			break;
		}
	}
	if(B)
	{
		r = n - 2;
		for(int i = block + 1;i * L <= n - 2;i++)
		{
			if(mn[i] < val)
			{
				for(int j = i * L;;j++)
				{
					if(f[j] < val)
					{
						r = j - 1;
						break;
					}
				}
				break;
			}
		}
	}
	B = 1;
	if(pos == 0) return r - pos + 2;
	for(int i = pos - 1;i >= block * L;i--)
	{
		if(f[i] < val)
		{
			l = i + 1;
			B = 0;
			break;
		}
	}
	if(B)
	{
		l = 0;
		for(int i = block - 1;i >= 0;i--)
		{
			if(mn[i] < val)
			{
				for(int j = i * L + L - 1;;j--)
				{
					if(f[j] < val)
					{
						l = j + 1;
						break;
					}
				}
			}
		}
	}
	debug() << show(l) show(pos) show(r);
	return r - l + 2;
}

int32_t main(){_
	//freopen("input","r",stdin);
	cin >> n >> m;
	for(int i = 0;i <= n + 1000;i++) f[i] = mn[i] = 1e9;
	for(int i = 1;i <= m;i++)
	{
		cin >> a[i] >> b[i] >> c[i];
		upd(min(a[i],b[i]),c[i]);
	}
	debug() << show(range(f,f + n));
	cin >> q;
	while(q--)
	{
		int t,x,y;
		cin >> t >> x >> y;
		if(t == 1) upd(min(a[x],b[x]),y);
		else
		{
			cout << qry(x,y) << '\n';
		}
	}
	return 0;
}









컴파일 시 표준 에러 (stderr) 메시지

bridges.cpp:4:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
 # pragma GCC optimization ("unroll-loops")
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...