Just got AC for this one.

I used 3 arrays one for the first number, one for the second and one for the result. Each one of them had 1000003 elements.

Using simple addition algorithm with I/O using scanf/printf(C++ code) I got AC in under 1 sec. So don't bother if you are not speed junkie

## Search found 20 matches

- Wed May 11, 2011 2:58 pm
- Forum: Volume 100 (10000-10099)
- Topic: 10013 - Super long sums
- Replies:
**212** - Views:
**41195**

- Sun May 08, 2011 7:02 pm
- Forum: Volume 107 (10700-10799)
- Topic: 10790 - How Many Points of Intersection?
- Replies:
**28** - Views:
**16557**

### Re: 10790 - How Many Points of Intersection?

Just got AC on this one. The problem boils down to bijection of a choose 2 and b choose 2. Which simplifies as stated by mf to (a(a - 1)) / 2 * (b(b - 1)) / 2 or even simpler (a*b*(a-1)*(b-1)) / 4 Be careful to use proper data types so input cases such as 20000 20000 provide the proper results :)

- Sun May 08, 2011 6:30 pm
- Forum: Volume 3 (300-399)
- Topic: 344 - Roman Digititis
- Replies:
**15** - Views:
**4514**

### Re: 344 Problem

Just got AC on this one :) Here is a neat way to convert decimal to roman numbers: const string romanOneToNine[] = {"", "A", "AA", "AAA", "AB", "B", "BA", "BAA", "BAAA", "AC"}; const string romanDigits[] = {"IVX", "XLC", "CDM", "M" }; string GetRomanDigit(unsigned num, unsigned power) { string resul...

- Sun May 08, 2011 1:23 pm
- Forum: Volume 107 (10700-10799)
- Topic: 10776 - Determine The Combination
- Replies:
**19** - Views:
**10157**

### Re: 10776 - Determine The combination

Just got AC on this one.

Simple way to do it is:

Simple way to do it is:

Code: Select all

```
1.Sort the input string
2.After generating the current combination the next one should start with a different character
```

- Tue May 03, 2011 7:27 am
- Forum: Volume 100 (10000-10099)
- Topic: 10020 - Minimal coverage
- Replies:
**57** - Views:
**20892**

### Re: 10020 - Minimal Coverage

Just got AC on this problem :) In this problem long is enough as you read the coordinates ( so no doubles or anything like that ... ). The greedy approach to solving this problem is really easy. 0. Some preconditions If segment.end < 0 -> skip if segment.start > M -> skip If segment.start <= 0 && se...

- Sun May 01, 2011 7:02 pm
- Forum: Volume 101 (10100-10199)
- Topic: 10194 - Football (aka Soccer)
- Replies:
**119** - Views:
**37899**

### Re: 10194 - Football (aka Soccer)

Just got AC on this problem.

For the C++ users:

The following should be the last line of your boolean comparator
strcasecmp is somehow not well documented function but the judge accepted my solution along with it

For the C++ users:

The following should be the last line of your boolean comparator

Code: Select all

```
return strcasecmp(team1Name, team2Name) < 0;
```

- Fri Apr 29, 2011 10:00 am
- Forum: Volume 5 (500-599)
- Topic: 507 - Jill Rides Again
- Replies:
**92** - Views:
**30609**

### Re: 507 - Jill rides again

Hi all, just got AC on this problem. For those of you who are wondering about solution to this problem, search for the Kadane's Algorithm which solves this problem in O(n) time. Some modifications are needed since the problem have some specific constraints about route length and order. These all can...

- Sat Jan 22, 2011 11:24 pm
- Forum: Volume 1 (100-199)
- Topic: 111 - History Grading
- Replies:
**135** - Views:
**22700**

### Re: 111 Why WA??

Just got AC. So for those of you who are having trouble reading the input and do not care particularly about the speed of it: cin >> n; unsigned t; for(unsigned i = 0; i < n; i++) { cin >> t; a[t] = i; } while(true) { for(unsigned i = 0; i < n; i++) { if(!(cin >> t)) { return 0; } b[t] = i; } cout <...

- Mon Dec 20, 2010 6:43 pm
- Forum: Volume 5 (500-599)
- Topic: 541 - Error Correction
- Replies:
**27** - Views:
**11936**

### Re: 541-error correction --help is wanted

A little tip:

It is enough to use matrix of bools (in C++ at least), since you have only bits

I was wondering is there any other way to solve this problem aside of the brute force approach i.e. how can one find if parity rule is not met?

It is enough to use matrix of bools (in C++ at least), since you have only bits

I was wondering is there any other way to solve this problem aside of the brute force approach i.e. how can one find if parity rule is not met?

- Sat Sep 11, 2010 8:19 pm
- Forum: Volume 103 (10300-10399)
- Topic: 10370 - Above Average
- Replies:
**62** - Views:
**19365**

### Re: 10370 - Above Average

Just got AC on this problem :) Some tips for those of you who want quick and dirty solution: 1. Use float or double ( I used double ) for calculating the average score and the percentage 2. In order to output the percentage use something like this: cout << fixed << setprecision(3) << percentage << "...

- Sat Sep 11, 2010 1:05 pm
- Forum: Volume 5 (500-599)
- Topic: 591 - Box of Bricks
- Replies:
**80** - Views:
**11670**

### Re: 591

Yes. You are right, no sorting is neededfaiem wrote:why u r sorting???

it is possible without sorting...and very fast...

- Fri Sep 10, 2010 10:28 pm
- Forum: Volume 100 (10000-10099)
- Topic: 10008 - What's Cryptanalysis?
- Replies:
**55** - Views:
**17711**

### Re: 10008 - What's Cryptanalysis?

Just got AC on this problem. Some tips: 1. Use something like: char c; while( (c = getchar()) != EOF) if(isalpha(c)) // handle char for handling your input. You don't care about individual lines! 2. I think that my implementation is too complex for such problem but is only 45 lines of C++. So consid...

- Mon Sep 06, 2010 2:33 pm
- Forum: Volume 5 (500-599)
- Topic: 591 - Box of Bricks
- Replies:
**80** - Views:
**11670**

### Re: 591

Hi! Just got AC :) Some tips: 1. Find the average height: total sum / number of towers 2. Sort the towers in asc order (for C++ guys, use <algorithm> sort() with vector or array if you want to get it done quickly) 3. For each tower with height > average: moves += tower height - average 4. Print the ...

- Sun Aug 15, 2010 2:20 pm
- Forum: Volume 100 (10000-10099)
- Topic: 10099 - The Tourist Guide
- Replies:
**91** - Views:
**29382**

### Re: 10099 - The Tourist Guide

Just got AC on this problem. Here are some thoughts: 1. After each scenario you should output one empty line! 2. It might be a good idea if you check startPoint == endPoint :) 3. If you don't care much about the speed use Floyd's All-pairs shortest path algorithm and use long for all your variables ...

- Sat Aug 14, 2010 8:57 pm
- Forum: Volume 100 (10000-10099)
- Topic: 10004 - Bicoloring
- Replies:
**93** - Views:
**30269**

### Re: 10004 - Bicoloring

Just got AC on this problem. Some tips: 1. Don't assume that there will be node 0, so don't start your BFS at node 0, use other trick :) 2. Color the starting node ( passed to your BFS func ) with color 1 and enqueue it for each adjacent node if not visited already mark visited color it with the opp...