Skip to content

Instantly share code, notes, and snippets.

Takuma Kageyama takageymt

  • Japan
Block or report user

Report or block takageymt

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View uvalive_7724.cpp
#include <bits/stdc++.h>
using namespace std;
char buf[5000001];
int main() {
int N;
while(scanf("%d", &N) != EOF) {
bitset<1010> gate[10];
View uvalive_6070.cpp
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
struct UnionFind {
vector<ll> sz, par, cost;
UnionFind(ll n):sz(n, 1), par(n), cost(n, 0) {
iota(par.begin(), par.end(), 0);
View my_db_util.hpp
#ifndef MY_DB_UTIL_HPP
#define MY_DB_UTIL_HPP
#include <iostream>
#include <stdexcept>
#include <exception>
#include <memory>
#include <string>
#include <sqlite3.h>
View MyDB.cpp
class MyDB {
sqlite3* db;
bool conn;
MyDB():db(nullptr), conn(false){}
~MyDB() {
if(conn) {
View get_all_words_in.cpp
std::vector<Word> get_all_words_in(const std::vector<Page>& pages) {
std::vector<Word> words;
std::map<std::string, int> word_conv;
int num_words = 0;
for(const Page& page : pages) {
std::vector<std::string> raw_words = filter_with_regex(get_words_in(page.url()), ".*\\.html$", false);
for(int i = 0; i < static_cast<int>(raw_words.size()); ++i) {
if(!word_conv.count(raw_words[i])) {
word_conv[raw_words[i]] = num_words++;
words.emplace_back(word_conv[raw_words[i]], raw_words[i]);
View get_pages.cpp
std::vector<Page> get_pages(const std::vector<std::string>& urls) {
std::vector<Page> pages;
std::map<std::string, int> url_conv;
for(int i = 0; i < static_cast<int>(urls.size()); ++i) {
pages.emplace_back(i, urls[i]);
url_conv[urls[i]] = i;
for(int i = 0; i < static_cast<int>(pages.size()); ++i) {
std::string dirpath = [](const std::string& url) {
View get_html_paths.cpp
std::vector<std::string> get_html_paths(const std::string& dirpath) {
std::vector<std::string> filepaths;
enum_dir_elements(dirpath, filepaths, false);
return filter_with_regex(filepaths, ".*\\.html$");
View PageRank.cpp
std::vector<double> PageRank(const std::vector<Page>& pages, const int K, const bool normalizable) {
std::map<int, int> pid_conv;
for(int i = 0; i < static_cast<int>(pages.size()); ++i) {
pid_conv[pages[i].id()] = i;
std::vector<double> importances(pages.size(), 1.0);
for(int k = 0; k < K; ++k) {
std::vector<double> sums(pages.size(), 0.0);
takageymt / get_associations.cpp
Created Jun 12, 2018
integrated exercise for software i: ex08
View get_associations.cpp
std::vector<double> get_associations(const std::vector<Page>& pages,
const std::vector<Word>& words,
const std::vector<std::string>& keywords,
const bool normalizable) {
std::map<int, int> pid_conv;
for(int i = 0; i < static_cast<int>(pages.size()); ++i) {
pid_conv[pages[i].id()] = i;
std::map<std::string, int> word_conv;
takageymt / aoj2691.cpp
Last active May 27, 2018
AOJ 2691: Cost Performance Flow
View aoj2691.cpp
#include <bits/stdc++.h>
using namespace std;
using Int = __int128_t;
Int abs128(Int val){return val<0?-val:val;}
ostream &operator<<(ostream &os,Int val){
__uint128_t tmp=abs128(val);
You can’t perform that action at this time.