Submission #948956

# Submission time Handle Problem Language Result Execution time Memory
948956 2024-03-18T17:27:37 Z vjudge1 Land of the Rainbow Gold (APIO17_rainbow) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#define endl '\n'
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define fo(i,n) for(auto i =0 ; i < n;i++)
#define fore(i,l,r) for(auto i = l; i < r;i++)
#define forex(i,r,l) for(auto i = r; i >= l; i--)
#define ffo(i,n) forex(i,n-1,0)
#define all(x) x.begin(),x.end()
#define lsb(x) x&(-x)
#define sz(x) (int)x.size()
#define gcd(a,b) __gcd(a,b)
#define vii vector<ii>
using namespace std;
using ii = pair<int,int>; using ll = long long; using ull = unsigned long long;
using vi = vector<ll>;
void valid(int in){cout<<((in)?"YES\n":"NO\n");return;}
vii posit;
void init(int n, int m, int sr ,int sc, int movs, char *moves){
    posit.pb({sr,sc});
    fo(i,movs){
        if(moves[i] == 'N')sr--;
        else if(moves[i]=='S')sr++;
        else if(moves[i]=='E')sc++;
        else if(moves[i]=='W')sc--;
        posit.pb({sr,sc});
    }
}
int colour(int r1, int c1, int r2 ,int c2){
    vi cont(c2+1, 0);
    for(auto v : posit){
        if(v.f >= r1 and v.f <= r2 and v.s >= c1+1 and v.s <= c2){
            cont[v.s]++;
        }
    }int con = 0;
    fore(i,c1,c2+1){
        con += (cont[i] == r2-r1+1);
    }return con + (cont[c2] != r2-r1+1);
}
void test_case(){
    int n,m; cin >> n >> m;
    int movs,q; cin >> movs >> q;
    int sr,sc; cin >> sr >> sc;
    char *moves; cin >> moves;
    init(n,m,sr,sc,movs,moves);
    while(q--){
        int r1,c1,r2,c2; cin >> r1 >> c1 >> r2 >> c2;
        cout << colour(r1,c1,r2,c2) << endl;
    }
}
int main(){cin.tie(0)->sync_with_stdio(0);
    int t;t=1;
    while(t--)test_case();
}

Compilation message

rainbow.cpp: In function 'void test_case()':
rainbow.cpp:46:25: warning: 'moves' is used uninitialized in this function [-Wuninitialized]
   46 |     char *moves; cin >> moves;
      |                         ^~~~~
/usr/bin/ld: /tmp/cc5bJAXV.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccQjLqMY.o:rainbow.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status