답안 #738384

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
738384 2023-05-08T15:46:25 Z myrcella 무지개나라 (APIO17_rainbow) C++17
0 / 100
11 ms 8284 KB
//by szh
#include<bits/stdc++.h>
using namespace std;
 
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pb push_back
#define debug(x) cerr<<#x<<"="<<x<<endl
#define pq priority_queue
#define inf 0x3f
#define rep(i,a,b) for (int i=a;i<(b);i++)
#define MP make_pair
#define SZ(x) (int(x.size()))
#define ll long long
#define mod 1000000007
#define ALL(x) x.begin(),x.end()
void inc(int &a,int b) {a=(a+b)%mod;}
void dec(int &a,int b) {a=(a-b+mod)%mod;}
int lowbit(int x) {return x&(-x);}
ll p0w(ll base,ll p) {ll ret=1;while(p>0){if (p%2ll==1ll) ret=ret*base%mod;base=base*base%mod;p/=2ll;}return ret;}
 
#include "rainbow.h"
 
const int maxn = 2e5+10;
 
const int dx[4] = {0,-1,1,0}, dy[4] = {1,0,0,-1};
vector <int> river[maxn];
int r,c;

void init(int R, int C, int sr, int sc, int M, char *S) {
	r = R, c = C;
	river[sr].pb(sc);
	rep(i,0,M) {
		if (S[i]=='S') sr++;
		else if (S[i]=='E') sc++;
		else if (S[i]=='W') sc--;
		else sr--;
		river[sr].pb(sc);
	}
	rep(i,0,r) sort(ALL(river[i]));
}
 
int colour(int ar, int ac, int br, int bc) {
	vector <pair<pii,int> > lstint,curint;
	int tot = 0;
	int ret = 0;
	rep(i,ar,br+1) {
		int lst = bc;
		while (!river[i].empty() and river[i].back()>bc) river[i].pop_back();
		while (!river[i].empty()) {
			int cur = river[i].back();
//			debug(i),debug(cur);
			if (cur+1<=lst) curint.pb({{cur+1,lst},tot++}),ret++;
			river[i].pop_back();
			while (!river[i].empty() and river[i].back() >= ac and river[i].back()==cur-1) river[i].pop_back(),cur--;
//			debug(cur);
			lst = cur-1;
		}
		if (ac<=lst) curint.pb({{ac,lst},tot++}),ret++;
		int cur = 0;
		rep(j,0,SZ(curint)) {
//			debug(curint[j].fi.fi),debug(curint[j].fi.se);
			while (cur<SZ(lstint) and lstint[cur].fi.se<curint[j].fi.fi) cur++;
			int curr = cur;
			int mn = mod;
			set <int> s;
			while (curr<SZ(lstint) and lstint[curr].fi.fi<=curint[j].fi.se) curr++,mn = min(mn,lstint[cur].se),s.insert(lstint[cur].se);
			if (mn!=mod) {
				curint[j].se = mn;
				ret--;
				rep(k,cur,curr) if (lstint[k].se>mn) lstint[k].se = mn;
				ret -= SZ(s)-1;	
			}
		}
		swap(curint,lstint);
		while (!curint.empty()) curint.pop_back();	
	}
	return ret;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 4948 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 4948 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 10 ms 5652 KB Output is correct
3 Incorrect 11 ms 8284 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 4948 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 4948 KB Output isn't correct
2 Halted 0 ms 0 KB -