Question for SRM 826 VisitPoints

9 posts Wed, Mar 30, 2022 at 05:42 AM in SRMs

I guess I understand this problem wrongly, but cannot figure out why. My strategy is to to visit each coordinate point in (0, 0) to (25, 25) in an order. For example, I move up from (0, 0) to (0, 25) at first, and move one grid east to (1, 25), and then move down from (1, 25) to (1, 0); and then move one grid east to (2, 0), and then move up again ...Why this stragegy is not correct? Below is my codes. Thanks!

#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <string>
#include <sstream>
#include <math.h> 
#include <string.h>
#include <algorithm>
#include <numeric>
#include <deque>
#include <climits>
#include <iomanip>

using namespace std;

typedef long long ll;

// const double M_PI = acos(-1.0);
// const double E = 2.71828182845904523536029;

class VisitPoints {
public:
    string visit(vector <int> X, vector <int> Y) {
        string ans;
        for (int i = 0; i < 25; i++) {
            char c = 'N';
            if (i % 2 == 1) {
                c = 'S';
            }
            for (int j = 0; j < 25; j++) {
                ans.push_back(c);
            }
            ans.push_back('E');
        }
        return ans;
    }
};
View: Threaded  |  Flat
+0
Sign In or Register to comment.