답안 #144551

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
144551 2019-08-17T06:57:10 Z arayi Pick (COI18_pick) C++17
0 / 100
2 ms 376 KB
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <math.h>
#include <vector>
#include <cstring>
#include <ctime>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <ctime>
#define fr first
#define sc second
#define MP make_pair
#define PB push_back
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define lli long long int
#define y1 arayikhalatyan
using namespace std;

lli gcd(lli a, lli b) {
	if (b == 0)
		return a;
	return gcd(b, a % b);
}
lli cg(lli n) {
	return n ^ (n >> 1);
}
lli SUM(lli a)
{
	return (a * (a + 1) / 2);
}
bool CAN(int x, int y, int n, int m)
{
	if (x >= 0 && y >= 0 && x < n && y < m)
	{
		return true;
	}
	return false;
}
double her(double x1, double y1, double x2, double y2)
{
	return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}
string strsum(string a, string b)
{
	int p = 0;
	string c;
	reverse(a.begin(), a.end());
	reverse(b.begin(), b.end());
	if (b.length() < a.length())
	{
		for (int i = b.length(); i < a.length(); i++)
		{
			b += "0";
		}
	}
	else
	{
		for (int i = a.length(); i < b.length(); i++)
		{
			a += "0";
		}
	}

	a += "0", b += "0";
	for (int i = 0; i < a.length(); i++)
	{
		c += (a[i] - '0' + b[i] - '0' + p) % 10 + '0';
		p = (a[i] + b[i] - '0' - '0' + p) / 10;
	}
	if (c[c.length() - 1] == '0') c.erase(c.length() - 1, 1);
	reverse(c.begin(), c.end());
	return c;
}
string strmin(string a, string b)
{
	if (a.length() > b.length()) return b;
	if (b.length() > a.length()) return a;
	for (int i = 0; i < a.length(); i++)
	{
		if (a[i] > b[i]) return b;
		if (b[i] > a[i]) return a;
	}
	return a;
}

char vow[] = { 'a', 'e', 'i', 'o', 'u' };
int dx[] = { 1, -1, 0, 0 };
int dy[] = { 0, 0, 1, -1 };



const int N = 1e6 + 30;
const lli mod = 998244353;

int a, b, c, d;
int x, y;
set < pair<int, int> > s;
set < pair<int, int> > ::iterator i1;
void rec(int a, int b, int c, int d)
{
	//cout << a << " " << b << " " << c << " " << d << "-" << x << " " << y << endl;
	if (!a && !b && !c && !d)
	{
		if (x == 0 && y == 0)
		{
			for (i1 = s.begin(); i1 != s.end(); ++i1)
			{
				cout << (*i1).fr << " " << (*i1).sc << endl;
			}
			exit(0);
		}
		return;
	}
	if (a)
	{
		if (s.find(MP(x, y + 1)) == s.end())
		{
			s.insert(MP(x, y + 1));
			y++;
			rec(a - 1, b, c, d);
			y--;
			s.erase(s.find(MP(x, y + 1)));
		}
		if (s.find(MP(x, y - 1)) == s.end())
		{
			s.insert(MP(x, y - 1));
			y--;
			rec(a - 1, b, c, d);
			y++;
			s.erase(s.find(MP(x, y - 1)));
		}
	}
	if (b)
	{
		if (s.find(MP(x + 1, y)) == s.end())
		{
			s.insert(MP(x + 1, y));
			x++;
			rec(a, b - 1, c, d);
			x--;
			s.erase(s.find(MP(x + 1, y)));
		}
		if (s.find(MP(x - 1, y)) == s.end())
		{
			s.insert(MP(x - 1, y));
			x--;
			rec(a, b - 1, c, d);
			x++;
			s.erase(s.find(MP(x - 1, y)));
		}
	}
	if (c)
	{
		if (s.find(MP(x + 1, y + 1)) == s.end())
		{
			s.insert(MP(x + 1, y + 1));
			y++;
			x++;
			rec(a, b, c - 1, d);
			y--;
			x--;
			s.erase(s.find(MP(x + 1, y + 1)));
		}
		if (s.find(MP(x - 1, y - 1)) == s.end())
		{
			s.insert(MP(x - 1, y - 1));
			y--;
			x--;
			rec(a, b, c - 1, d);
			y++;
			x++;
			s.erase(s.find(MP(x - 1, y - 1)));
		}
	}
	if (d)
	{
		if (s.find(MP(x + 1, y - 1)) == s.end())
		{
			s.insert(MP(x + 1, y - 1));
			y--;
			x++;
			rec(a, b, c, d - 1);
			y++;
			x--;
			s.erase(s.find(MP(x + 1, y - 1)));
		}
		if (s.find(MP(x - 1, y + 1)) == s.end())
		{
			s.insert(MP(x - 1, y + 1));
			y++;
			x--;
			rec(a, b, c, d - 1);
			y--;
			x++;
			s.erase(s.find(MP(x - 1, y + 1)));
		}
	}
}
int main()
{
	fastio;
	cin >> a >> b >> c >> d;
	swap(a, b);
	rec(a, b, c, d);
	return 0;
}

Compilation message

pick.cpp: In function 'std::__cxx11::string strsum(std::__cxx11::string, std::__cxx11::string)':
pick.cpp:57:30: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int i = b.length(); i < a.length(); i++)
                            ~~^~~~~~~~~~~~
pick.cpp:64:30: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int i = a.length(); i < b.length(); i++)
                            ~~^~~~~~~~~~~~
pick.cpp:71:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < a.length(); i++)
                  ~~^~~~~~~~~~~~
pick.cpp: In function 'std::__cxx11::string strmin(std::__cxx11::string, std::__cxx11::string)':
pick.cpp:84:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < a.length(); i++)
                  ~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB number of sticks is not consistent with the given input
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 256 KB not a valid stick
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB not a valid stick
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB not a valid stick
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB not a valid stick
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB not a valid stick
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB not a valid stick
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB number of sticks is not consistent with the given input
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB number of sticks is not consistent with the given input
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB number of sticks is not consistent with the given input
2 Halted 0 ms 0 KB -