ÃßõµÇ¾ú½À´Ï´Ù.
|
´ÜÃà URL: https://humoruniv.com/program5434 URL º¹»ç |
¿Í ´ÙÇß´Ù!
½ÇÇà -> ¿À·ù
¤¾¤¾ ¿À·ù°¡ ÀÖ¾ú³× ¼öÁ¤ÇÏ°í ´Ù½Ã!
½ÇÇà -> Åë°ú
ÄÚµå äÁ¡ -> fail -> 0Á¡(ºÎºÐÁ¡¼ö ¾øÀ½)
?
??? : ´Ï°¡ ¹» Ʋ·È´Âµ¥ ±×°Ô ¹ºÁø ¾È¾Ë·ÁÁÜ.
??? : ºÎºÐÁ¡¼ö ¾øÀ¸´Ï 0Á¡ ¤µ¤¡
¼Ò½ºÄÚµå ¿äûÀÌ ÀÖ¾î ¿Ã¸³´Ï´Ù.
´ëȸ ÆäÀÌÁö¿¡´Â mainÇÔ¼ö¸¦ Á¦°ÅÇÏ°í ºÙ¿©³Ö±âÇß½À´Ï´Ù.
/*
//1¹ø¹®Á¦
#include <vector>
#include <map>
#include <iostream>
#include <string>
using namespace std;
vector<vector<bool>> checkList;
int maxY, maxX;
int checkPixel(vector<vector<int>> *picture, int y, int x, int curColor) {
int color = (*picture)[y][x];
if (checkList[y][x] == true || color == 0 || color != curColor)
return 0;
checkList[y][x] = true;
int count = 1;
if (y > 0) {
count += checkPixel(picture, y - 1, x, curColor);
}
if (y < maxY - 1) {
count += checkPixel(picture, y + 1, x, curColor);
}
if (x > 0) {
count += checkPixel(picture, y, x - 1, curColor);
}
if (x < maxX - 1) {
count += checkPixel(picture, y, x + 1, curColor);
}
return count;
}
// Àü¿ª º¯¼ö¸¦ Á¤ÀÇÇÒ °æ¿ì ÇÔ¼ö ³»¿¡ ÃʱâÈ Äڵ带 ²À ÀÛ¼ºÇØÁÖ¼¼¿ä.
vector<int> solution(int m, int n, vector<vector<int>> picture) {
int number_of_area = 0;
int max_size_of_one_area = 0;
maxY = m;
maxX = n;
checkList.clear();
for (int i = 0; i < m; i++) {
vector<bool> list;
for (int o = 0; o < n; o++) {
list.push_back(false);
}
checkList.push_back(list);
}
for (int i = 0; i < m; i++) {
for (int o = 0; o < n; o++) {
if (checkList[i][o] == true || picture[i][o] == 0)
continue;
cout << i << " " << o << endl;
int result = checkPixel(&picture, i, o, picture[i][o]);
if (result != 0) {
cout << result << endl;
number_of_area++;
if (max_size_of_one_area < result)
max_size_of_one_area = result;
}
}
}
vector<int> answer(2);
answer[0] = number_of_area;
answer[1] = max_size_of_one_area;
return answer;
}
void main() {
vector<vector<int>> picture { {1, 1, 1, 0},{1, 1, 1, 0},{0, 0, 0, 1},{0, 0, 0, 1},{0, 0, 0, 1},{0, 0, 0, 1} };
solution(6, 4, picture);
}*/
/*
//2¹ø¹®Á¦
#include <vector>
#include <iostream>
using namespace std;
int MOD = 20170805;
#define RIGHT 0
#define DOWN 1
#define FREE 0
#define BLOCK 1
#define NOTURN 2
int maxY, maxX;
// Àü¿ª º¯¼ö¸¦ Á¤ÀÇÇÒ °æ¿ì ÇÔ¼ö ³»¿¡ ÃʱâÈ Äڵ带 ²À ÀÛ¼ºÇØÁÖ¼¼¿ä.
int solution(int m, int n, vector<vector<int>> city_map) {
maxY = m;
maxX = n;
vector<vector<int*>> data;
data.clear();
for (int i = 0; i < m; i++) {
vector<int*> list;
for (int o = 0; o < n; o++) {
int *arr = new int[2]{ 0, 0 };
list.push_back(arr);
}
data.push_back(list);
}
data[m - 1][n - 2][RIGHT] = 1;
data[m - 2][n - 1][DOWN] = 1;
int *ptr;
for (int i = m - 1; i >= 0; i--) {
for (int o = n - 1; o >= 0; o--) {
if ((i == m - 1 && o >= n - 2) || (i >= m - 2 && o == n - 1))
continue;
ptr = &data[i][o][RIGHT];
if (o < n - 1) {
if (city_map[i][o + 1] == FREE) {
(*ptr) = data[i][o + 1][RIGHT];
(*ptr) += data[i][o + 1][DOWN];
if (*ptr >= MOD) {
(*ptr) = (*ptr) % MOD;
}
}
else if (city_map[i][o + 1] == NOTURN) {
(*ptr) = data[i][o + 1][RIGHT];
}
else {
(*ptr) = 0;
}
}
ptr = &data[i][o][DOWN];
if (i < m - 1) {
if (city_map[i + 1][o] == FREE) {
(*ptr) = data[i + 1][o][RIGHT];
(*ptr) += data[i + 1][o][DOWN];
if (*ptr >= MOD) {
(*ptr) = (*ptr) % MOD;
}
}
else if (city_map[i + 1][o] == NOTURN) {
(*ptr) = data[i + 1][o][DOWN];
}
else {
(*ptr) = 0;
}
}
}
}
int answer = (data[0][0][0] + data[0][0][1]) % MOD;
for (int i = 0; i < m; i++) {
for (int o = 0; o < n; o++) {
delete data[i][o];
}
}
return answer;
}
void main() {
vector<vector<int>> picture{{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 , 0, 0, 0, 0, 0, 0 , 0, 0, 0, 0, 0, 0 }, {0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0 , 0, 0, 0, 0, 1, 0 , 0, 0, 0, 0, 1, 0 }, {1, 0, 0, 0, 0, 0,1, 0, 0, 0, 0, 0 ,1, 0, 0, 0, 0, 0 ,1, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 , 0, 0, 0, 0, 0, 0 , 0, 0, 0, 0, 0, 0 },{ 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0 , 0, 0, 0, 0, 1, 0 , 0, 0, 0, 0, 1, 0 },{ 1, 0, 0, 0, 0, 0,1, 0, 0, 0, 0, 0 ,1, 0, 0, 0, 0, 0 ,1, 0, 0, 0, 0, 0 } ,
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 , 0, 0, 0, 0, 0, 0 , 0, 0, 0, 0, 0, 0 },{ 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0 , 0, 0, 0, 0, 1, 0 , 0, 0, 0, 0, 1, 0 },{ 1, 0, 0, 0, 0, 0,1, 0, 0, 0, 0, 0 ,1, 0, 0, 0, 0, 0 ,1, 0, 0, 0, 0, 0 } ,
{ 0, 0, 0, 0, 0, 0, 0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 , 0, 0, 0, 0, 1, 0 , 0, 0, 0, 0, 1, 0 },{ 1, 0, 0, 0, 0, 0,1, 0, 0, 0, 0, 0 ,1, 0, 0, 0, 0, 0 ,1, 0, 0, 0, 0, 0 } };
int result = solution(24, 24, picture);
cout << result << endl;
}*/
/*
//3¹ø¹®Á¦
#include <string>
#include <iostream>
using namespace std;
bool isSmall(char c) {
if (c >= 97 && c <= 122)
return true;
return false;
}
bool isBig(char c) {
if (c >= 65 && c <= 90)
return true;
return false;
}
string usedList = "";
// Àü¿ª º¯¼ö¸¦ Á¤ÀÇÇÒ °æ¿ì ÇÔ¼ö ³»¿¡ ÃʱâÈ Äڵ带 ²À ÀÛ¼ºÇØÁÖ¼¼¿ä.
string removeMark(string sentence) {
int start = -1;
int end = -1;
int cur = 0;
int len = sentence.length();
string answer = "";
for (; cur < len; cur++) {
char keyCode = sentence[cur];
if (isSmall(keyCode)) { //¼Ò¹®ÀÚ
if (usedList.find(keyCode) != -1) { //»ç¿ëÇÑ Æ¯¼ö¹®ÀÚ°¡ ¶Ç ´Ù½Ã µîÀåÇÏ´Â ¹®¹ý ¿À·ù.
return "invalid";
}
if (cur < len - 1 && (end == -1 || end + 1 != cur) && (cur != 0 && isBig(sentence[cur - 1])) && isBig(sentence[cur + 1])) {
start = cur;
answer += sentence[cur - 1];
answer += sentence[cur + 1];
while (cur < len - 2 && sentence[cur + 2] == keyCode) { //°°Àº ¹®ÀÚ¸¦ °è¼Ó °Ë»ö
if (isBig(sentence[cur + 1]) == false) //»çÀ̰ªÀº ´ë¹®ÀÚ¿©¾ß µÊ
return "invalid";
cur += 2;
answer += sentence[cur + 1];
}
if (isBig(sentence[cur + 1]) == false) //³¡ºÎºÐµµ ´ë¹®ÀÚ¿©¾ß µÊ
return "invalid";
cur++;
end = cur;
answer += " ";
usedList += keyCode;
continue;
}
if (cur < len - 2 && isBig(sentence[cur + 1])) {
start = cur;
cur++;
for (; cur < len; cur++) {
if (sentence[cur] == keyCode) {
if (isBig(sentence[cur - 1]) == false)
return "invalid";
end = cur;
string result = sentence.substr(start + 1, end - (start + 1));
result = removeMark(result);
if (result == "invalid")
return "invalid";
answer += result;
break;
}
}
answer += " ";
usedList += keyCode;
continue;
}
else {
return "invalid";
}
}
}
if (answer == "")
return sentence;
if (answer[answer.length() - 1] == ' ') //¹®Àå ³¡ÀÇ °ø¹é Á¦°Å
answer.pop_back();
return answer;
}
string solution(string sentence) {
usedList = "";
return removeMark(sentence);
}
void main() {
cout << solution("qHaEaLaLaOqbWORLDbYcO") << endl; //HELLO WORLD YO
cout << solution("qHtatEtatLtatLtatOqbWORLDbYcO") << endl; //invalid(ÀÌÁß)
cout << solution("oqHaEaLaLaOqobWORLDbYcO") << endl; //invalid(¿¬¼Ó)
cout << solution("HaEaLaLaObWORLDbYaO") << endl; //invalid(Áߺ¹)
cout << solution("SpIpGpOpNpGJqOqA") << endl; //SIGONG JOA
cout << solution("AxAxAxAoBoBoB") << endl; //invalid(¿¬°è)
}*/
/*
//4¹ø¹®Á¦
#include <string>
#include <iostream>
#define __DEBUG
using namespace std;
unsigned int GetMinNumber(int count) {
int num = 1;
num = pow(3, count);
num += count * 2;
return num;
}
unsigned int GetMaxNumber(int count) {
int num = 1;
for (int i = 0; i < count; i++) {
num *= 3;
num += 2;
}
return num;
}
int CountSuccesses(string str, double target, double value, int canMul, int canAdd) {
int success = 0;
if (canMul == 1) {
double result = value;
result *= 3;
result += canAdd;
#ifdef __DEBUG
string str2 = str + "x";
for (int i = 0; i < canAdd; i++)
str2 += "+";
cout << str2 << " : " << result;
#endif
if (target == result) {
#ifdef __DEBUG
cout << " find";
#endif
success = 1;
}
if (target < result) {
#ifdef __DEBUG
cout << " over";
#endif
success = -1;
}
#ifdef __DEBUG
cout << endl;
#endif
return success;
}
double powValue = pow(3, canMul);
if (value + canAdd < target / powValue || value > (target - canAdd) / powValue)
return 0;
for (int i = 0; i <= canAdd - (canMul - 1) * 2; i++) {
int result;
#ifdef __DEBUG
string str2 = str + "x";
for (int o = 0; o < i; o++)
str2 += "+";
result = CountSuccesses(str2, target, value * 3 + i, canMul - 1, canAdd - i);
#else
result = CountSuccesses(str, target, value * 3 + i, canMul - 1, canAdd - i);
#endif
if (result == -1)
return success;
else
success += result;
}
return success;
}
// Àü¿ª º¯¼ö¸¦ Á¤ÀÇÇÒ °æ¿ì ÇÔ¼ö ³»¿¡ ÃʱâÈ Äڵ带 ²À ÀÛ¼ºÇØÁÖ¼¼¿ä.
int solution(int n) {
if (n < 5 || n > pow(2, 31) - 1)
return 0;
int answer = 0;
//3´Ü°íÀ½ Ƚ¼ö
int count = 2;
while (true) {
if (GetMaxNumber(count) > n)
break;
if (GetMinNumber(count + 1) > n) //max¿Í ´ÙÀ½ min »çÀÌ ±¸°£
return 0;
count++;
}
answer = CountSuccesses("", n, 1, count, count * 2);
return answer;
}
void main() {
cout << 15 << " : " << solution(15) << endl;
cout << "---------------------" << endl;
cout << 24 << " : " << solution(24) << endl;
cout << "---------------------" << endl;
cout << 41 << " : " << solution(41) << endl;
cout << "---------------------" << endl;
cout << 2147483647 << " : " << solution(2147483647) << endl;
cout << "---------------------" << endl;
}*/
/*
//5¹ø¹®Á¦
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;
bool Compare(vector<int> a, vector<int> b) {
return (a[0] != b[0]) ? (a[0] < b[0]) : (a[1] < b[1]);
}
int GetY(vector<int> *target) {
return (*target)[0];
}
int GetX(vector<int> *target) {
return (*target)[1];
}
// Àü¿ª º¯¼ö¸¦ Á¤ÀÇÇÒ °æ¿ì ÇÔ¼ö ³»¿¡ ÃʱâÈ Äڵ带 ²À ÀÛ¼ºÇØÁÖ¼¼¿ä.
int solution(int n, vector<vector<int>> data) {
int answer = 0;
sort(data.begin(), data.end(), Compare);
int t_y, t_x, c_y, c_x, min_x, max_x, p_x;
int len = data.size();
for (int i = 0; i < len; i++) {
t_y = GetY(&data[i]);
t_x = GetX(&data[i]);
for (int o = i; o < len; o++) {
c_y = GetY(&data[o]);
c_x = GetX(&data[o]);
if (t_y == c_y || t_x == c_x) //¸éÀû 0Àº ºñ±³´ë»ó¿¡¼ Á¦¿Ü
continue;
min_x = min(t_x, c_x);
max_x = max(t_x, c_x);
bool pass = true;
for (int p = i; p < len; p++) {
if (GetY(&data[p]) > c_y)
break;
p_x = GetX(&data[p]);
if (p_x > min_x && p_x < max_x) {
pass = false;
break;
}
}
if (pass) {
answer++;
}
}
}
return answer;
}
void main() {
vector<vector<int>> data{ { 1, 1 },{ 0, 2 },{ 2, 0 },{ 0, 0 } };
cout << solution(4, data) << endl;
}*/
// 1, 2, 3, 5¹ø¹®Á¦ Ç®¾úÀ½. ±× Áß 1¹ø¸¸ 100Á¡, ³ª¸ÓÁö´Â ºÎºÐÁ¡¼ö ¾ø¾î¼ 0Á¡.
// 4¹øÀº ½Ã°£ÀÌ ´Ù µÅ¼ ³ªÁß¿¡ Ç®¾úÀ½.
|
¡ã ´ÙÀ½±Û | ´Ôµé ¿ä»õ monthly.js°¡ ¶á´Ù´Âµ¥ ¹¹ÁÒ? | ij³ª´Ù»Í¸ÂÀº»õ³¢ |
![]() ![]() ![]() ![]() |
2017-08-08 [18:19] |
¡å ÀÌÀü±Û | Ȥ½Ã ½º¸¶Æ® ±â±â °ü·Ã °³¹ß ÇϽô ºÐµé (Áß¼Ò±â¾÷À̳ª ½ºÅ¸Æ®¾÷) | º¸°íº¿ |
![]() ![]() ![]() ![]() |
2017-08-03 [15:03] |
![]() |
·¹¸ó¶ø½ºÅ¸ |
°ªÀ» ¹Þ¾Æ¼ ¸®ÅÏÇØ¾ß Çϴµ¥ ±×³É ȸ鿡¸¸ Ãâ·ÂÇØ¼ ±×·±°Å ¾Æ´Ï¿¡¿ä?
|
00 |
![]() ![]() ![]() ![]() |
2017-08-07 |
||||||
|
|||||||||||
![]() |
![]() jic6012 |
ÄܼÖâÀº Á¦°¡ µû·Î Å×½ºÆ®ÇѰſ¡¿ä. ¸®Åϰª ´Ù Á༠±âº»À¸·Î ÁÖ¾îÁø Å×½ºÆ®ÄÉÀ̽º´Â ´Ù Åë°úÇÔ...
|
00 |
![]() ![]() ![]() |
2017-08-07 |
||||||
![]() |
![]() jic6012 |
ÄÚµå äÁ¡¿¡¼ ´ëü ¾î¶² ÀڷḦ Áá±â¿¡ Ʋ¸®´Â°ÇÁö ¾Ë·ÁÁÖÁú ¾Ê¾Æ¼ ¹®Á¦¿´ÁÒ.
|
00 |
![]() ![]() ![]() |
2017-08-07 |
||||||
|
|||||||||||
![]() |
![]() jic6012 |
¾î¶² ÀÚ·á¿¡ ¾î¶² Ãâ·ÂÀ¸·Î Ʋ·È´ÂÁö ¾Ë·ÁÁÖ±â¶óµµ ÇÏÁö ºÎºÐÁ¡¼ö ¾øÀÌ 0Á¡¸¸ Ç¥½ÃÇÔ Ä«Ä«¿À ºÎµéºÎµé...
|
00 |
![]() ![]() ![]() |
2017-08-07 |
||||||
![]() |
![]() ·¹¸ó¶ø½ºÅ¸ |
¾Æ ±×·¸±º¿ä......
|
00 |
![]() ![]() ![]() |
2017-08-07 |
||||||
![]() |
¾ÆÀ̾ðÈ£±× |
À̰нÅûµµ Çߴµ¥...ÇÏÇÊ ±×³¯¿¡ ³·ÀáÀÚ¹ö·Á¼ ³õħ¤Ì¤Ì
|
00 |
![]() ![]() ![]() ![]() |
2017-08-08 |
||||||
![]() |
![]() ¾ÆÀ̾ðÈ£±× |
¹æ½ÄÀº Á¤¿ÃÀ̶û °°³×¿ä. ºÎºÐ¹®Á¦°¡ ¿©·¯°³ Àִµ¥, °¢ ºÎºÐ¹®Á¦¸¶´Ù ÀԷ°ªÀÌ 5°³¾¿ ȤÀº ±×ÀÌ»ó Á¸ÀçÇϰí, ÀԷ°ª ´Ù Á¤´äµÇ¾ß ºÎºÐ¹®Á¦Çϳª Ŭ¸®¾î
|
00 |
![]() ![]() ![]() |
2017-08-08 |
||||||
![]() |
![]() jic6012 |
īī¿À ´ëȸ¿¡¼± Å×½ºÆ® ÄÉÀ̽º¸¸ ¸î°¡Áö ¾Ë·ÁÁÖ°í Á¡¼ö µé¾î°¡´Â ÀԷ°ªÀ» ¼û±â´øµ¥ Á¤¿Ã¿¡¼´Â ´Ù ¾Ë·ÁÁÖ³ª¿ä?
|
00 |
![]() ![]() ![]() |
2017-08-08 |
||||||
![]() |
![]() ¾ÆÀ̾ðÈ£±× |
¾Æ´Ï¿©, Á¤¿Ãµµ ¸¶Âù°¡Áö¿¡¿ä. ´ë½Å ÈùÆ®°°Àº°Ô ÀÖ±äÇØ¿ä. »çÁøÃ³·³¿ä. º¸Åë Á¶°ÇÀÇ °æ°èÁöÁ¡°°Àº°÷¿¡¼ ¿¹¿Üó¸® À߸øÇؼ Ʋ¸®´Â°Ô ¸¹±äÇÏÁ®
|
00 |
![]() ![]() ![]() |
2017-08-08 |
¡ã ´ÙÀ½±Û | ´Ôµé ¿ä»õ monthly.js°¡ ¶á´Ù´Âµ¥ ¹¹ÁÒ? | ij³ª´Ù»Í¸ÂÀº»õ³¢ |
![]() ![]() ![]() ![]() |
2017-08-08 [18:19] |
¡å ÀÌÀü±Û | Ȥ½Ã ½º¸¶Æ® ±â±â °ü·Ã °³¹ß ÇϽô ºÐµé (Áß¼Ò±â¾÷À̳ª ½ºÅ¸Æ®¾÷) | º¸°íº¿ |
![]() ![]() ![]() ![]() |
2017-08-03 [15:03] |