Scanner sc = new Scanner(System.in);
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
Scanner sc = new Scanner(new FileReader("file_name"));
const user = new Promise((resolve, reject) => { | |
console.log('User promise prepared') | |
resolve({ name: 'sagheer' }) | |
}) | |
user.message = new Promise((resolve, reject) => { | |
console.log('Message promise prepared') | |
resolve(['Hey', 'There!']) | |
}) | |
user.then(r => { |
package benchmark | |
// Processor: Intel® Core™ i3-2348M CPU @ 2.30GHz × 4 | |
// Memory: 5.7 GiB | |
// | |
// Benchmarking on 100,000 records | |
// - record key length = 50 | |
// - length of common key (prefix) among all records = 15 | |
// - record value length = 5 | |
// |
static void run(InputReader in, OutputWriter out) { | |
int n = in.readRequestCount(); | |
children = new ArrayList[n]; // maximum number of versions is n | |
relevantQueries = new ArrayList[n]; | |
for(int i = 0; i < n; ++i) { | |
children[i] = new ArrayList<>(); // stores a list of versions that are directly produced from version i | |
relevantQueries[i] = new ArrayList<>(); // stores a list of queries that are asked on version i | |
} |
Build and Combine for Segment trees with nodes carrying more than one variable. The example below is on a segment tree that can find maximum and its frequency in a given interval [L, R]. The combine()
function will also be used in update()
and query()
.
static class Node
{
int max, freq;
Node(int a, int b)
{
max = a;
The practice sheet is designed to let you:
The spreadsheet is divided into sheets, one for each mentor group (sheets are named by the mentors' names at the bottom of the spreadsheet). Every ACMer will have a column where he/she can update his progress.
Add problem links here. Have a look at markdown cheatsheet
:-use_module(library(clpfd)). | |
reporters(["Corey", "Jimmy", "Lois", "Perry"]). | |
locations(["Bayonne", "New Hope", "Port Charles", "South Amboy"]). | |
events(["30-pound baby", "blimp launching", "skyscraper dedication", "beached whale"]). | |
match():- | |
reporters(R), length(R, N), length(L, N), length(E, N), | |
L ins 1..4, E ins 1..4, all_distinct(L), all_distinct(E), | |
% 1. Reporter of event 1 didn't go to location 2 or 4 |
import java.io.IOException; | |
import java.util.Arrays; | |
import java.util.Scanner; | |
// Input: Number of players, showering time per player | |
public class Shower { | |
public static void main(String[] args) throws IOException { | |
Scanner sc = new Scanner(System.in); |
:-use_module(library(clpfd)). | |
shower(Times, End):- | |
maplist(player_task, Times, Tasks, Es), | |
Es ins 1..100, | |
cumulative(Tasks, [limit(3)]), | |
max_list2(Es, End), | |
once(labeling([min(End)], Es)). | |
player_task(Time, task(S, Time, E, 1, _), E):- S #>= 0. |