Submission #981372

# Submission time Handle Problem Language Result Execution time Memory
981372 2024-05-13T06:17:59 Z pcc Land of the Rainbow Gold (APIO17_rainbow) C++17
0 / 100
3000 ms 37816 KB
#include "rainbow.h"
#include <bits/stdc++.h>
using namespace std;

#define pii pair<int,int>
#define fs first
#define sc second

const int mxn = 2e5+10;
pii dir[] = {{0,1},{1,0},{1,1}};
vector<pii> v;

void init(int R, int C, int sr, int sc, int M, char *S) {
	pii now = pii(sr,sc);
	v.push_back(now);
	for(int i = 0;i<M;i++){
		if(S[i] == 'N')now.fs--;
		else if(S[i] == 'S')now.fs++;
		else if(S[i] == 'E')now.sc++;
		else if(S[i] == 'W')now.sc--;
		v.push_back(now);
	}
	sort(v.begin(),v.end());
	v.resize(unique(v.begin(),v.end())-v.begin());
}

set<pii> st;

int colour(int ar, int ac, int br, int bc) {
	vector<pii> vv;
	for(auto &i:v){
		if(i.fs<ar||i.fs>br||i.sc<ac||i.sc>bc)continue;
		vv.push_back(i);
	}
	for(int i = ar-1;i<=br+1;i++){
		vv.push_back(pii(i,ac-1));
		vv.push_back(pii(i,bc+1));
	}
	for(int i = ac-1;i<=bc+1;i++){
		vv.push_back(pii(ar-1,i));
		vv.push_back(pii(br+1,i));
	}
	v = vv;
	sort(v.begin(),v.end());
	v.resize(unique(v.begin(),v.end())-v.begin());
	for(auto &i:v)cerr<<i.fs<<','<<i.sc<<' ';cerr<<endl;
	for(auto &i:v)st.insert(i);
	int ecnt = 0,vcnt = 0;
	vcnt = v.size();
	for(auto &i:v){
		if(st.find(pii(i.fs+1,i.sc)) != st.end())ecnt++;
		if(st.find(pii(i.fs,i.sc+1)) != st.end())ecnt++;
	}
	int ans = 2+ecnt-vcnt;
	cerr<<vcnt<<' '<<ecnt<<endl;
	for(auto &i:v){
		int c = 0;
		for(auto &d:dir){
			if(st.find(pii(i.fs+d.fs,i.sc+d.sc)) != st.end())c++;
		}
		if(c == 3)ans--;
	}
	return ans-1;
}

Compilation message

rainbow.cpp: In function 'int colour(int, int, int, int)':
rainbow.cpp:46:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   46 |  for(auto &i:v)cerr<<i.fs<<','<<i.sc<<' ';cerr<<endl;
      |  ^~~
rainbow.cpp:46:43: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   46 |  for(auto &i:v)cerr<<i.fs<<','<<i.sc<<' ';cerr<<endl;
      |                                           ^~~~
# Verdict Execution time Memory Grader output
1 Incorrect 193 ms 740 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1710 ms 27720 KB Output is correct
3 Correct 1830 ms 27612 KB Output is correct
4 Correct 1588 ms 22588 KB Output is correct
5 Correct 792 ms 12604 KB Output is correct
6 Correct 2472 ms 37816 KB Output is correct
7 Execution timed out 3025 ms 21660 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 193 ms 740 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 193 ms 740 KB Output isn't correct
2 Halted 0 ms 0 KB -