Menu Sidebar
Menu

divide and conquer

[LintCode] Nuts & Bolts Problem

public void sortNutsAndBolts(String[] nuts, String[] bolts, NBComparator compare) { // write your code here sort(nuts,bolts,0,nuts.length-1, compare); } public void sort(String[] nuts, String[] bolts, int l, int h, NBComparator compare) { if(l < h){ int p = partition(nuts, l,h, bolts[h], compare); partition(bolts, l,h,nuts[p], compare); sort(nuts, bolts, l, p-1,compare); sort(nuts, bolts, p+1, h,compare); } } public int […]

Codeforces Round #313 (Div. 2) D. Equivalent Strings

原题:http://codeforces.com/contest/560/problem/D 题目大意: 给字符串a和b, 定义a和b是等价的,如果: a和b相等. a等分成a1,a2,b等分成b1,b2, (a1==b1 && a2==b2) || (a2==b1 && a1==b2) 分析: 就暴呗…我也不知道为什么我暴就报错, 是因为java的原因么, 我看人家同样码用c++, 都飞快的. public void solve(int testNumber, InputReader in, OutputWriter out) { String a = in.readString(); String b = in.readString(); if (solve(a,b)) out.print(“YES”); else out.print(“NO”); } private boolean solve(String a, String b) { if (a.length() % 2 != 0 || […]

书脊

这青苔碧瓦堆, 俺曾睡风流觉, 将五十年兴亡看饱.

November 2024
M T W T F S S
 123
45678910
11121314151617
18192021222324
252627282930