Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions 190523/wangmin/pg42746.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>

using namespace std;

bool func(string a, string b){
return a+b > b+a ? true : false;
}

string solution(vector<int> numbers) {
string answer = "";
vector<string> 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;
}
21 changes: 21 additions & 0 deletions 190524/wangmin/pg42747.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>

using namespace std;

int solution(vector<int> 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;
}

49 changes: 49 additions & 0 deletions 190527/wangmin/pg42840.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

vector<int> solution(vector<int> answers) {
vector<int> one = {1,2,3,4,5};
vector<int> two = {2,1,2,3,2,4,2,5};
vector<int> 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<int> answer;
if(max == oneCount) answer.push_back(1);
if(max == twoCount) answer.push_back(2);
if(max == threeCount) answer.push_back(3);


return answer;
}
53 changes: 53 additions & 0 deletions 190530/wangmin/bj1913.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
//https://www.acmicpc.net/problem/1913

#include <iostream>
#include <vector>

using namespace std;

int main () {
int n,a;
cin >> n >> a;

vector<vector<int>> vec = vector<vector<int>>(n,(vector<int>(n,0)));

vector<int> start ={n/2,n/2};
vector<vector<int>> right = {{-1,0},{0,1},{1,0},{0,-1}};
vector<int> head = {-1,0};

vector<int> 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<<endl;




}