Saratov State University :: Online Contester


::Go
- home
- news
- register
- update personal info
- problemset archive
- submit
- status online
- standing
- contests
- virtual contests
- forum
- statistic
- FAQ
- links
- projects

::Poll
Are you registered on Codeforces?
Yes
No
What is it???

[results]

::webboard

Some Problem in C# (to site admins)
Author: Mirzakhmet Syzdykov
ID: 004300
Problem: 196
Contest: 0
Date: 2011-08-14 21:54:59

Hello this is to site admins too:
Why my solution gives memory limit exceeded if I write in C# the following code (please fix it somehow or check my solution):

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Sgu196
{
class Program
{
static int[] nextInt(string s)
{
int i, k = -1, len = 0;
int[] result = new int[2];
for (i = 0; i < s.Length; ++i)
if ("0123456789".IndexOf(s[i]) >= 0)
{
if (k == -1) k = 0;
k = k * 10 + (int)s[i] - (int)'0';
}
else
{
if (k >= 0) result[len++] = k;
k = -1;
}
if (k >= 0) result[len++] = k;
return result;
}
static void Main(string[] args)
{
int[] ret = nextInt(Console.ReadLine());
int i, n = ret[0], m = ret[1];
int[] deg = new int[n];
int[][] arc = new int[m][];
for (i = 0; i < n; ++i) deg[i] = 0;
for (i = 0; i < m; ++i) {
arc[i] = nextInt(Console.ReadLine());
--arc[i][0]; --arc[i][1];
++deg[arc[i][0]]; ++deg[arc[i][1]];
}
int result = 0;
for (i = 0; i < m; i++)
result += deg[arc[i][0]] + deg[arc[i][1]];
Console.WriteLine(result.ToString());
}
}
}


see sub-tree reply to that message


::Login
Forgot password?

::News
22.10.12 - The problems from the Southern Subregional Programming Contest 2012 added to the problemset archive (542 - 553).
22.10.12 - After the start of the contest the statements in PDF will be available by the link.
23.10.11 - The problems from the Southern Subregional Programming Contest 2011 added to the problemset archive (530 - 541).

::Counter

Server time: 2017-11-23 06:19:00Online Contester Team © 2002 - 2016. All rights reserved.