1342 - That Nice Euler Circuit

All about problems in Volume 13. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

Post Reply
brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

1342 - That Nice Euler Circuit

Post by brianfry713 »

Use this thread to discuss this problem.
Check input and AC output for thousands of problems on uDebug!
metaphysis
Experienced poster
Posts: 139
Joined: Wed May 18, 2011 3:04 pm

Re: 1342 - That Nice Euler Circuit

Post by metaphysis »

Test data generator.

Code: Select all

#include <iostream>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>

using namespace std;

struct point
{
    int x, y;
    
    bool operator == (point p)
    {
        return x == p.x && y == p.y;
    }
};

int main(int argc, char *argv[])
{
    srand(time(NULL));

    for (int c = 1; c <= 25; c++)
    {
        int N = rand() % 297 + 2;
        cout << N << '\n';
        
        vector<point> points;
        
        int vertices = 1;
        while (vertices < N)
        {
            int x = rand() % 300, y = rand() % 300;
            if (rand() % 2 == 0) x *= -1;
            if (rand() % 2 == 0) y *= -1;
            if (find(points.begin(), points.end(), point{x, y}) != points.end()) continue;
            if (vertices > 0) cout << ' ';
            cout << x << ' ' << y;
            points.push_back(point{x, y});
            vertices++;
        }
        
        cout << ' ' << points.front().x << ' ' << points.front().y << '\n';
    }
    
    cout << "0\n";
    
    return 0;
}
Post Reply

Return to “Volume 13 (1300-1399)”