Submission #975514

# Submission time Handle Problem Language Result Execution time Memory
975514 2024-05-05T11:34:12 Z De3b0o Land of the Rainbow Gold (APIO17_rainbow) C++14
11 / 100
3000 ms 9176 KB
#include "rainbow.h"
#include<bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define in insert
#define pb push_back
#define ppb pop_back()
#define d3 ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define cans cout << ans << "\n";
#define yes cout << "Yes" << "\n";
#define no cout << "No" << "\n";
#define pll pair<ll,ll>
#define lin cout << "\n";
#define sqr 340
#define mod 1000000007
#define mid ((l+r)/2)
#define lc (2*n)
#define rc (2*n+1)

using namespace std;

ll m;
string s;
bool mp[1009][1009];
bool vis[1009][1009];
ll Ar , Ac , Br , Bc;

void river(ll i , ll j , ll idx)
{
    mp[i][j]=1;
    if(idx==m)
        return;
    if(s[idx]=='N')
        river(i-1,j,idx+1);
    if(s[idx]=='S')
        river(i+1,j,idx+1);
    if(s[idx]=='W')
        river(i,j-1,idx+1);
    if(s[idx]=='E')
        river(i,j+1,idx+1);
}

void dfs(ll i , ll j)
{
    if(i<Ar||i>Br||j<Ac||j>Bc||vis[i][j]||mp[i][j])
        return;
    vis[i][j]=1;
    dfs(i+1,j);
    dfs(i-1,j);
    dfs(i,j+1);
    dfs(i,j-1);
}

void init(int R, int C, int sr, int sc, int M, char *S)
{
    s=S;
    m=M;
    river(sr,sc,0);
}

int colour(int ar, int ac, int br, int bc)
{
    ll ans = 0;
    Ar = ar;
    Br = br;
    Ac = ac;
    Bc = bc;
    for(int i = ar ; br>=i ; i++)
    {
        for(int j = ac ; bc>=j ; j++)
        {
            if(vis[i][j]||mp[i][j])
                continue;
            dfs(i,j);
            ans++;
        }
    }
    for(int i = ar ; br>=i ; i++)
        for(int j = ac ; bc>=j ; j++)
            vis[i][j]=0;
    return ans;
}

# Verdict Execution time Memory Grader output
1 Correct 2 ms 348 KB Output is correct
2 Correct 4 ms 676 KB Output is correct
3 Correct 12 ms 604 KB Output is correct
4 Correct 12 ms 600 KB Output is correct
5 Correct 5 ms 604 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 11 ms 648 KB Output is correct
12 Correct 9 ms 604 KB Output is correct
13 Correct 6 ms 604 KB Output is correct
14 Correct 4 ms 604 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Execution timed out 3082 ms 7804 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Runtime error 1 ms 860 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 348 KB Output is correct
2 Correct 4 ms 676 KB Output is correct
3 Correct 12 ms 604 KB Output is correct
4 Correct 12 ms 600 KB Output is correct
5 Correct 5 ms 604 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 11 ms 648 KB Output is correct
12 Correct 9 ms 604 KB Output is correct
13 Correct 6 ms 604 KB Output is correct
14 Correct 4 ms 604 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Execution timed out 3067 ms 9176 KB Time limit exceeded
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 348 KB Output is correct
2 Correct 4 ms 676 KB Output is correct
3 Correct 12 ms 604 KB Output is correct
4 Correct 12 ms 600 KB Output is correct
5 Correct 5 ms 604 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 11 ms 648 KB Output is correct
12 Correct 9 ms 604 KB Output is correct
13 Correct 6 ms 604 KB Output is correct
14 Correct 4 ms 604 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Execution timed out 3067 ms 9176 KB Time limit exceeded
19 Halted 0 ms 0 KB -