diff --git a/190523/wangmin/pg42746.cpp b/190523/wangmin/pg42746.cpp new file mode 100644 index 0000000..2fbd7a5 --- /dev/null +++ b/190523/wangmin/pg42746.cpp @@ -0,0 +1,28 @@ +#include +#include +#include +#include + +using namespace std; + +bool func(string a, string b){ + return a+b > b+a ? true : false; +} + +string solution(vector numbers) { + string answer = ""; + vector str; + for(int i = 0 ; i < numbers.size(); i++){ + str.push_back(to_string(numbers[i])); + } + + sort(str.begin(), str.end(), func); + for(int i = 0; i < str.size(); i++){ + answer += str[i]; + } + if(answer[0] == '0'){ + return "0"; + } + + return answer; +} \ No newline at end of file diff --git a/190524/wangmin/pg42747.cpp b/190524/wangmin/pg42747.cpp new file mode 100644 index 0000000..8d1425a --- /dev/null +++ b/190524/wangmin/pg42747.cpp @@ -0,0 +1,21 @@ +#include +#include +#include +#include + +using namespace std; + +int solution(vector citations) { + int h; + sort(citations.begin(),citations.end()); + for(int i = 0; i< citations.size(); i++){ + h = citations.size()-i; + + if(citations[i] >= h){ + return h; + } + + } + return 0; +} + diff --git a/190527/wangmin/pg42840.cpp b/190527/wangmin/pg42840.cpp new file mode 100644 index 0000000..941df3c --- /dev/null +++ b/190527/wangmin/pg42840.cpp @@ -0,0 +1,49 @@ +#include +#include +#include + +using namespace std; + +vector solution(vector answers) { + vector one = {1,2,3,4,5}; + vector two = {2,1,2,3,2,4,2,5}; + vector three = {3,3,1,1,2,2,4,4,5,5}; + + int oneCount = 0; + int twoCount = 0; + int threeCount = 0; + + for(int i = 0; i < answers.size(); i++){ + if(answers[i] == one[i%one.size()]){ + oneCount++; + } + } + + int max = oneCount; + + for(int i = 0; i < answers.size(); i++){ + if(answers[i] == two[i%two.size()]){ + twoCount++; + } + } + + max = (twoCount > max) ? twoCount : max; + + for(int i = 0; i < answers.size(); i++){ + if(answers[i] == three[i%three.size()]){ + threeCount++; + } + } + + max = (threeCount > max) ? threeCount : max; + + + + vector answer; + if(max == oneCount) answer.push_back(1); + if(max == twoCount) answer.push_back(2); + if(max == threeCount) answer.push_back(3); + + + return answer; +} \ No newline at end of file diff --git a/190530/wangmin/bj1913.cpp b/190530/wangmin/bj1913.cpp new file mode 100644 index 0000000..af70292 --- /dev/null +++ b/190530/wangmin/bj1913.cpp @@ -0,0 +1,53 @@ +//https://www.acmicpc.net/problem/1913 + +#include +#include + +using namespace std; + +int main () { + int n,a; + cin >> n >> a; + + vector> vec = vector>(n,(vector(n,0))); + + vector start ={n/2,n/2}; + vector> right = {{-1,0},{0,1},{1,0},{0,-1}}; + vector head = {-1,0}; + + vector aindex = {0,0}; + + // vec[start[0]][start[1]] = 1; + int rightindex = 0; + for(int i = 1; i <= n*n; i ++){ + // vec[start[0],start[1]] + vec[start[0]][start[1]] = i; + + if(i == a){ + aindex = {start[0],start[1]}; + } + + if(vec[start[0]+right[rightindex%4][0]][start[1]+right[rightindex%4][1]] == 0){ + head = right[rightindex%4]; + start[0] = start[0]+head[0]; + start[1] = start[1]+head[1]; + rightindex++; + }else{ + start[0] = start[0]+head[0]; + start[1] = start[1]+head[1]; + } + } + + for(int i = 0; i < n; i++){ + for(int j = 0; j < n; j++){ + cout << vec[i][j]<<" "; + } + cout << "\n"; + } + + cout << aindex[0]+1 << " " << aindex[1]+1<