#define DEBUG 0
#include <bits/stdc++.h>
using namespace std;
#if DEBUG
// basic debugging macros
int __i__,__j__;
#define printLine(l) for(__i__=0;__i__<l;__i__++){cout<<"-";}cout<<endl
#define printLine2(l,c) for(__i__=0;__i__<l;__i__++){cout<<c;}cout<<endl
#define printVar(n) cout<<#n<<": "<<n<<endl
#define printArr(a,l) cout<<#a<<": ";for(__i__=0;__i__<l;__i__++){cout<<a[__i__]<<" ";}cout<<endl
#define print2dArr(a,r,c) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<a[__i__][__j__]<<" ";}cout<<endl;}
#define print2dArr2(a,r,c,l) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<setw(l)<<setfill(' ')<<a[__i__][__j__]<<" ";}cout<<endl;}
// advanced debugging class
// debug 1,2,'A',"test";
class _Debug {
public:
template<typename T>
_Debug& operator,(T val) {
cout << val << endl;
return *this;
}
};
#define debug _Debug(),
#else
#define printLine(l)
#define printLine2(l,c)
#define printVar(n)
#define printArr(a,l)
#define print2dArr(a,r,c)
#define print2dArr2(a,r,c,l)
#define debug
#endif
// define
#define MAX_VAL 999999999
#define MAX_VAL_2 999999999999999999LL
#define EPS 1e-6
#define mp make_pair
#define pb push_back
// typedef
typedef unsigned int UI;
typedef long long int LLI;
typedef unsigned long long int ULLI;
typedef unsigned short int US;
typedef pair<int,int> pii;
typedef pair<LLI,LLI> plli;
typedef vector<int> vi;
typedef vector<LLI> vlli;
typedef vector<pii> vpii;
typedef vector<plli> vplli;
// ---------- END OF TEMPLATE ----------
#include "rainbow.h"
int r,c;
int ll,rr,dd,uu;
vpii p;
int grid[50][50];
void init(int R,int C,int sr,int sc,int M,char *S) {
int i;
r = R,c = C;
sr--,sc--;
p.pb(mp(sr,sc));
for (i = 0; i < M; i++) {
if (S[i] == 'N') sr--;
else if (S[i] == 'S') sr++;
else if (S[i] == 'W') sc--;
else sc++;
p.pb(mp(sr,sc));
}
ll = C-1,rr = 0,dd = R-1,uu = 0;
sort(p.begin(),p.end());
p.resize(unique(p.begin(),p.end())-p.begin());
for (i = 0; i < p.size(); i++) {
ll = min(ll,p[i].second),rr = max(rr,p[i].second);
dd = min(dd,p[i].first),uu = max(uu,p[i].first);
grid[p[i].first][p[i].second] = 1;
}
}
int colour(int ar,int ac,int br,int bc) {
ar--,ac--,br--,bc--;
int i,j,ans = 0;
for (i = ar; i <= br; i++) {
for (j = ac; j <= bc; j++) {
if (!grid[i][j]) ans++;
if ((i < br) && !grid[i][j] && !grid[i+1][j]) ans--;
if ((j < bc) && !grid[i][j] && !grid[i][j+1]) ans--;
if ((i < br) && (j < bc) && !grid[i][j] && !grid[i+1][j] && !grid[i][j+1] && !grid[i+1][j+1]) ans++;
}
}
if ((ar < dd) && (br > uu) && (ac < ll) && (bc > rr)) ans++;
return ans;
}
Compilation message
rainbow.cpp: In function 'void init(int, int, int, int, int, char*)':
rainbow.cpp:78:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (i = 0; i < p.size(); i++) {
~~^~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
248 KB |
Output is correct |
2 |
Correct |
5 ms |
356 KB |
Output is correct |
3 |
Correct |
6 ms |
448 KB |
Output is correct |
4 |
Correct |
7 ms |
540 KB |
Output is correct |
5 |
Correct |
5 ms |
784 KB |
Output is correct |
6 |
Correct |
2 ms |
784 KB |
Output is correct |
7 |
Correct |
2 ms |
784 KB |
Output is correct |
8 |
Correct |
2 ms |
784 KB |
Output is correct |
9 |
Correct |
2 ms |
784 KB |
Output is correct |
10 |
Correct |
2 ms |
784 KB |
Output is correct |
11 |
Correct |
6 ms |
784 KB |
Output is correct |
12 |
Correct |
7 ms |
784 KB |
Output is correct |
13 |
Correct |
7 ms |
820 KB |
Output is correct |
14 |
Correct |
6 ms |
848 KB |
Output is correct |
15 |
Correct |
3 ms |
848 KB |
Output is correct |
16 |
Correct |
2 ms |
848 KB |
Output is correct |
17 |
Correct |
3 ms |
848 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
848 KB |
Output is correct |
2 |
Correct |
3 ms |
848 KB |
Output is correct |
3 |
Runtime error |
11 ms |
2264 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
848 KB |
Output is correct |
2 |
Runtime error |
11 ms |
3076 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
248 KB |
Output is correct |
2 |
Correct |
5 ms |
356 KB |
Output is correct |
3 |
Correct |
6 ms |
448 KB |
Output is correct |
4 |
Correct |
7 ms |
540 KB |
Output is correct |
5 |
Correct |
5 ms |
784 KB |
Output is correct |
6 |
Correct |
2 ms |
784 KB |
Output is correct |
7 |
Correct |
2 ms |
784 KB |
Output is correct |
8 |
Correct |
2 ms |
784 KB |
Output is correct |
9 |
Correct |
2 ms |
784 KB |
Output is correct |
10 |
Correct |
2 ms |
784 KB |
Output is correct |
11 |
Correct |
6 ms |
784 KB |
Output is correct |
12 |
Correct |
7 ms |
784 KB |
Output is correct |
13 |
Correct |
7 ms |
820 KB |
Output is correct |
14 |
Correct |
6 ms |
848 KB |
Output is correct |
15 |
Correct |
3 ms |
848 KB |
Output is correct |
16 |
Correct |
2 ms |
848 KB |
Output is correct |
17 |
Correct |
3 ms |
848 KB |
Output is correct |
18 |
Runtime error |
17 ms |
3500 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
19 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
248 KB |
Output is correct |
2 |
Correct |
5 ms |
356 KB |
Output is correct |
3 |
Correct |
6 ms |
448 KB |
Output is correct |
4 |
Correct |
7 ms |
540 KB |
Output is correct |
5 |
Correct |
5 ms |
784 KB |
Output is correct |
6 |
Correct |
2 ms |
784 KB |
Output is correct |
7 |
Correct |
2 ms |
784 KB |
Output is correct |
8 |
Correct |
2 ms |
784 KB |
Output is correct |
9 |
Correct |
2 ms |
784 KB |
Output is correct |
10 |
Correct |
2 ms |
784 KB |
Output is correct |
11 |
Correct |
6 ms |
784 KB |
Output is correct |
12 |
Correct |
7 ms |
784 KB |
Output is correct |
13 |
Correct |
7 ms |
820 KB |
Output is correct |
14 |
Correct |
6 ms |
848 KB |
Output is correct |
15 |
Correct |
3 ms |
848 KB |
Output is correct |
16 |
Correct |
2 ms |
848 KB |
Output is correct |
17 |
Correct |
3 ms |
848 KB |
Output is correct |
18 |
Runtime error |
17 ms |
3500 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
19 |
Halted |
0 ms |
0 KB |
- |