Codeforces Round #368 Div. 2 review

Link Codeforces Round #368 Div. 2 (Contest 707)   A. Brain’s Photos Problem Just need to check if color (Cyan, Magenta or Yellow) exists or not in the photo.

  B. Bakery Problem The problem sentence looks long, but after summarize, you just need to find the path between flour storage city and non flour storage city with minimum distance. But to find out these city path, I was using vector which is not fast enough and I got TLE during contest.

  We can make search fast, in constant time by using Array to set a type of city.

  C. Pythagorean Triples Problem Consider some cases to […]

Continue reading →

scanf and printf are much faster than cin and cout

When I’m solving the Codeforces problem, 707D. Persistent Bookcase, I made some comparison for the performance of I/O function. scanf() and printf() cin >> and cout <<   Test Let’s start from C++ common way, below code uses cin >> and cout <<

It took 748 ms. Next, (old-school,) C way of implementation using scanf() and printf()

It took only 171 ms.   Result function time scanf() and printf() 171 ms cin >> and cout << 748 ms In this experiment, it appears that the speed of cin and cout is much much slower than scanf() and printf(), the difference is indeed quite huge. The overhead of cin and cout took more than 500 ms! You might get a […]

Continue reading →

AtCoder Regular Contest 060 review

Link ARC 060 top page Editorial C: Tak and Cards – 高橋君とカード Dynamic programming I could come up only full search using bit operation during the contest. But it can be solved by DP. Below is full score (Section 3.3 of editorial) implementation.

  D: Digit Sum – 桁和 I came up different approach from editorial. Let \(a_i\) be \(i\)-th digit with base \(b\). Then, $$ n = \sum_i b^i a_i  $$ $$ s = f(b, n) = \sum_i a_i  $$ applies. If we subtract these equation, we obtain $$ n – s = \sum_i (b^i – 1) a_i  $$ Both side should be integer, and right hand side […]

Continue reading →

Chainer class introduction


Chainer is a library for deep learning. You can implement current trend network e.g. CNN (Convolutional Neural Network), RNN (Recurrent Neural Network) etc. Chainer official document * The post is written in 2016 July, with Chainer version 1.10, but Chainer is still in active development and some of the functionality specification may change in the future. Variable, functions, links and Chain At first, please read Introduction to Chainer. To summarize, input – output relationship of deep neural network is maintained by computational graph internally, which is constructed using Variable, functions, links and Chain. Once deep neural network is constructed, forward/backward propagation can be executed for training. VariableVariable will be used […]

Continue reading →

SeRanet: Quick start guide

This post explains SeRanet project, super resolution software through deep learning. Preparation Dependencies – third party library Install python, pip The software is written in python, and I’m using python version 2.7.6. If you are using OS Ubuntu 14.04, python2 is pre-installed by default. So you don’t need to install explicitly. The version of python can be checked by typing 

 in the terminal. If you can’t find python, then try below.

  To install third party python library, pip command is often used. To install pip, type below in command line

Install popular libraries, numpy, scipy, matplotlib numpy, scipy, matplotlib are widely used for data processing in python. […]

Continue reading →

IntelliJ Plugin Development introduction: PersistStateComponent

This post explains IntelliJ IDEA Plugin development. The source code explained here is uploaded in official repository as a CLion plugin, please check Single File Execution Plugin on github. Save value for IntelliJ Plugin If your plugin want to keep some configuration value and you want to save the values in storage, PersistentStateComponent can be used in IntelliJ IDEA plugin development. Ref Persisting State of Components   Make a class implments PersistentStateComponent Create new Java class, and add implements PersistentStateComponent<T>. Following hands on example, I will introduce easy quick implementation for this class. I made SingleFileExecutionConfig class which implements PersistentStateComponent<SingleFileExecutionConfig>. So the State type T is same with created class. To implement this interface PersistentStateComponent<T>, we need […]

Continue reading →

IntelliJ Plugin Development introduction: ApplicationConfigurable, ProjectConfigurable


[Update 2016.5.12] I uploaded Single File Execution Plugin on github. This post is for IntelliJ IDEA Plugin development. Configurable – Adding a configuration menu of Plugin to the Settings dialog If your plugin want user to allow some settings, we want to show configuration UI. We can show it on the IDEA settings dialog by implementing Configurable. This post introduces quick implementation for ApplicationConfigurable and ProjectConfigurable. I’m summarizing it because I could not find many references for IntelliJ IDEA Plugin development, and I also might have mistake. Ref:  Customizing the IDEA Settings Dialog Configurable IDEA Making class implements Configurable At first, create new java class. Here I made Let this class implement SearchableConfigurable. SearchableConfigurable […]

Continue reading →

IntelliJ Plugin Development introduction: GUI form designing


This post explains IntelliJ IDEA Plugin development. GUI form and Dialog IntelliJ provides 2 types of GUI component called GUI form and Dialog. IntelliJ uses special XML format with extension .form to design GUI component. Form is similar to Android’s res/layout xml files, and it makes easy to developing GUI on IntelliJ platform. Ref Creating and Opening Forms GUI Designer Basics Creating new GUI form or Dialog can be done by right click on src → New → GUI Form or Dialog. Detail explanation for each GUI component is done later.  For both components, form file (extension .form) and bound class (extension .java) will be created.   Understanding .form What is the […]

Continue reading →

Source code reading of waifu2x

Memo for self study. SRCNN – Super resolution by deep convolutional neural network Recently many application is developed using deep learning. waifu2x is a image super resolution application using convolutional neural network. The source code is open at github. It is developed using torch7, so the Lua programming language is used. I have never used Lua, but it is similar to python, so reading Lua source code was not so difficult without further study.  waifu2x supports upscaling (“scale”) and noise reduction (“noise”), but I will focus on scaling function here.  * Actually same CNN network architecture is used for upscaling, and noise reduction, they work in same way. Main difference is only training set used during training.  […]

Continue reading →

Install Android phone’s app on Android TV via Wifi


  As far as I know, this is one of the most convenient method to transfer files between Android devices and transfer & install Android apps in apk format. If you want to transfer by using USB, not by Wifi see old post “Install Android phone’s application to Android TV“. Sideloading apps on Android TV Many of the Android phone/tablet’s apps are not on the Google play store on Android TV (Nexus Player, Sony BRAVIA Android TV, NVIDIA Shield etc…). Many famous Android phone app is not correspond to Android TV yet, for example Browser app: Chrome, Firefox, Opera, UC Browser… SNS app: Facebook, Twitter, What’s app, … System/performance app: Antutu, CPU  […]

Continue reading →