Skip to content

Instantly share code, notes, and snippets.

View sifue's full-sized avatar

Soichiro Yoshimura sifue

View GitHub Profile
@sifue
sifue / main.cpp
Created July 7, 2016 13:27
素数判定
#include <iostream>
#include <unordered_map>
using namespace std;
int is_prime_f(int n) {
int i;
if(n < 2)
return -1;
else if(n == 2)
return 1;
@sifue
sifue / main.cpp
Created July 7, 2016 13:29
連立方程式
#include <iostream>
#include <vector>
#include <sstream>
#include <iomanip>
using namespace std;
vector<string> split(const string &s, char delim) {
vector<string> elems;
stringstream ss(s);
@sifue
sifue / main.cpp
Created July 9, 2016 03:32
Overlaps of Seals (解けず)
#include <iostream>
#include <vector>
#include <stack>
using namespace std;
struct Point {
double x;
double y;
};
@sifue
sifue / sample.txt
Created July 9, 2016 03:34
Overlaps of Sealsのデータセット
15
3.14979,8.51743
2.39506,3.84915
2.68432,5.39095
5.61904,9.16332
7.85653,4.75593
2.84021,5.41511
1.79500,8.59211
7.55389,8.17604
4.70665,4.66125
@sifue
sifue / main.cpp
Created July 9, 2016 12:44
四角形が凹んでいるかどうか(ベクトルと外積計算の実装有り)
#include <iostream>
using namespace std;
struct Vector {
double x;
double y;
};
bool is_c_inner(double xa, double ya, double xb, double yb, double xc, double yc, double xd, double yd) {
@sifue
sifue / main.cpp
Created July 9, 2016 15:11
直交性を判定する問題、精度に要注意…。
#include <iostream>
#include <cmath>
using namespace std;
bool is_orth(double xa, double ya, double xb, double yb, double xc, double yc, double xd, double yd) {
double inner_product = (xa-xb)*(xc-xd) + (ya-yb)*(yc-yd);
return fabs(inner_product) < 1e-10;
}
@sifue
sifue / main.cpp
Created July 10, 2016 14:56
Overlap 同士の組み合わせでチャレンジしたもの。 ただし組み合せ量の100個は行けず。
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>
using namespace std;
template <typename Tlist, typename Tfunc>
@sifue
sifue / main.cpp
Created July 10, 2016 18:06
複素数で書きなおしてみるOverlap(Wrong Answer)
#include <iostream>
#include <complex>
#include <vector>
#include <stack>
using namespace std;
template<class T> bool operator<(const complex<T> &a, const complex<T> &b){
return a.real() == b.real() ? a.imag() < b.imag() : a.real() < b.real();
}
@sifue
sifue / main.cpp
Created July 11, 2016 10:31
シールの重なり (Overlap) 解けたコード
#include <iostream>
#include <complex>
#include <vector>
#include <stack>
using namespace std;
template<class T> bool operator<(const complex<T> &a, const complex<T> &b){
return a.real() == b.real() ? a.imag() < b.imag() : a.real() < b.real();
}
#include <iostream>
#include <complex>
#include <vector>
#include <stack>
using namespace std;
template<class T> bool operator<(const complex<T> &a, const complex<T> &b){
return a.real() == b.real() ? a.imag() < b.imag() : a.real() < b.real();
}