MPGHCC Results

Posts 1–11 of 11 · Page 1 of 1
MPGHCC Results
http://www.mpgh.net/forum/31-c-c/131...g-contest.html

Congratualtions for Seamone for winning with 150 points!

Here are the answers:

Problems 1 :

Code:
#include <iostream>

using namespace std;

int main(void){

	freopen("count.txt","r",stdin);
	
	int t;
	for(i=0;i<5;i++){
	
		int n;
		int leecher=0,coder=0;
		
		cin>>n;
		
		for(i=0;i<n;i++){
			int postcount;
			int rep;
			cin>>postcount;
			cin>>rep;
			
			if(postcount*rep>=500)coder++;
			else leecher++;
		}
		
		printf("There are %d Coder(s) and %d Leecher(s).\n",coder,leecher);
	
	}



}
Problem 2: DoS Attack!

Code:
#include <iostream>

using namespace std;

int main(void){

freopen("dosattack.txt","r",stdin);

int t;

for(t=0;t<5;t++){

	int i;
	int n;
	int filter;
	cin>>n;
	cin>>filter;
	int id=0,connect=0;
	int arr[100];
	for(i=0;i<n;i++){
		cin>>arr[i];
	}
	for(i=0;i<n;i++){
		int te***ount=0;
		while(arr[i+1]==arr[i]){
		i++;
		te***ount++;}
		te***ount++;
		if(te***ount>filter){
			id = arr[i];
			connect=te***ount;
		}
		
	}
	if(connect)printf("DoS Alert! Connection ID of %d of the same %d connections.",id,connect);
	else cout<<"No DoS detected!";
	cout<<endl;

}

}
Problem 3: Trojan Firewall

Code:
#include <iostream>

using namespace std;

int main(void){

//freopen("trojan.txt","r",stdin);

int t;

for(t=0;t<5;t++){

	char str[100];
	
	cin>>str;
	
	int sum=0;
	int group;
	int i;
	
	if(strlen(str)%4==0)group=strlen(str)/4;
	else group=(strlen(str)/4)+1;
	
	for(i=0;i<strlen(str);i+=4){
		sum+=str[i]-'A'+1;
	}

	if(sum%group==0)printf("Trojan with code %d!",sum/group);
	else cout<<"Not a trojan!";
	cout<<endl;

}



}
Problem 4: Server

Code:
#include <iostream>

using namespace std;

int compare (const void * a,const void * b){ 
return ( *(int*)a - *(int*)b);
} //courtesy of cpluscplus reference

int main(void){

freopen("server.txt","r",stdin);

int t;

for(t=0;t<5;t++){

	int n;
	int arr[100];
	cin>>n;
	int i;
	for(i=0;i<n;i++)cin>>arr[i];
	
	qsort(arr,n,sizeof(int),compare);
	
	if(n%2==1)printf("Server will be located at %d.",arr[n/2]);
	else printf("Server will be located at %f.",(float)(arr[n/2]+arr[(n/2)-1])/2);
	cout<<endl;
}



}
Problem 5: Shortest path

Don't feel like doing it right now but its BFS / DFS.



The next contest will start this Saturday and will end the next Sunday. I will be changing the format of the contest and will try to be more specific on each question. If you have any questions/comments/suggestions feel free to reply to this post, PM me or email me.
I'm all for spurring on the folks here for a little mental stimulation so Kudos for taking this upon yourself to get people thinking - However, If you do another, Please do make those improvements because there were definite issues with how you posted this one.

I ran a bunch of 'tests' a while ago - Do a search on my old posts with 'IQOD' in the title from way back when for perhaps some clearer questions (doesn't need to complicated, could be something simple like this one) (or if you want me to look your post over to see whether or not someone else would think it's confusing etc feel free to PM me, I'd be glad to help out)

Some things to consider imo:

You should specify HOW you will be 'scoring'. There is no simple right/wrong way of doing some things, so explain how are you deciding what's worth more points; e.g. Performance of X Iterations? (if so, how many? 5? 10? 1000000? ) Elegance? Easy of readability? Proper Architecture / Use of functions/classes etc instead of piling everything in main? (would seem you get negative points for that currently ) Application of Standard Design patterns? Simple Personal Preference? Who gets closest to how you would've written it? (Impression so far is either of the last two).

If one person does a while-loop and the other a for-loop while a 3rd uses an iterator over a vector in a different class, but they all output the same result, who gets more points and why?

Also, having a problem that can have multiple results/answers is asking for trouble (like #4 unless that is properly defined up front which it obviously wasn't) because people could come up with algorithms that work with some of the provided samples and thus think they have it figured out, but then do not with others.

If I may suggest - if you're doing anything with 'test data' files. Generate those files yourself first, attach those and let the people work with that (and for god's sake get away from this nasty line by line text file format stuff... yuck.. )


Anyway, as you probably saw I didn't bother resubmitting since frankly it irritated me the descriptions were so vague and you were expecting 1 cpp file while I had mine structure in multiple (and I actually finally had some time to clean it up and make it into 1 program. I was going to break each problem out in a DLL for a dynamic architecture, but that was going a little too far over the top hahah)

Though on the flip side - if that is a requirement of submission (It is YOUR competition so you get to set the rules) you should state this clearly up front and simply say: Don't make multiple CPP Files or Classes or whatever (even though that's normally good form). That way people would clearly know what's expected.

I'd much prefer my code(which supports 'n' test cases) & solution structure (see attached) vs the posted solutions, but that's just me I've attached it in case people want to see some alternatives and see that modified A* Path solution (no diagonals, per posted sample - so I had to 'cripple' mine, otherwise mine did it in 5 less steps )

Anyway this is just some constructive criticism , so i'm looking forward to see what else you come up with.


(btw mixing cin with printf? lol someone couldn't make up their minds what IO method to use..)
mpghcontest(2).rarattachment deleted · 2 downloads before removal
Hey BA Thx for replying with your constructive criticism and I'll keep your suggestions in mind. As this was my first contest i have organized I have little experience in such. I defiently had issues with specifics and I will definitly improve next time.

In your regards for scoring, I planned to give 20 points for each test case you get correct and 10 points for every day you submit earlier. In the case of a tie I would have judged on the running time to determine the winner.

For question #4, while I was constructing the question it didn't occur to me that it would have multiple answers until the middle of the contest so apologies for that. I should have made you output the minimum total distance to the server. (The answer was to take the median btw).

I also should have put some limits to how big the input was like 1<n<100 and should have clarified the input was from file and there were 5 cases in the file.

I mixed cin and printf since i liked the use of %d and stuff in printf but cin was easier single string output.
Well congrats to Sealione, I know he was working hard on this, and he prbly did a good job. TBH I got distracted with other stuff after about the first two days, Your code is so much shorter then mine too.. I overcomplicated things when I should have kept it simple. That is my problem and something I need to work on. I also encourage you all to take a look at BA's code. Its very elegant/well-written. Pretty cool how he combined all the projects together.

Perhaps next time we could do something without textfiles o_O... something more creative. I would like that. Maybe something where you just have to accomplish a task and ur method of doing it is totally up to you.
Why06 you see, text files make it a lot easier to mark and add up the points. What do you mean by something more creative? Could you elaborate on that?
Quote Originally Posted by zhaoyun333 View Post
Why06 you see, text files make it a lot easier to mark and add up the points. What do you mean by something more creative? Could you elaborate on that?
Like, for instance create a program to post a message on MPGH for you. Or Create a program that causes something really annoying but non-harmful to happen. (like a program that automatically minimizes whichever window you have up =P.

Or something constructive. Create a program to search through memory for a value. Oh this is a good one: a program that will automatically add numbers together anywhere. Rather Im typing in notepad or in word, or even in this post. And change 2+2 to 4,

Okay maybe something easier.... how about a program to calculate the days till my next birthday, by entering in the the birth date, or something to calculate the average word size in a paper, Something not really specific where all that matters is the endgame, not how you got there.
I like the adding numbers and days till birthday one but the memory searching and minimzing thign I want to get away from. They require no thinking whatsoever and you could basically leech it from wherever. I want to promote using your brain for coding and showing people that coding isnt just for hacking.
I think problems where you need to develop your own algorithm etc are always much more interesting. I may post a competition of my own for one I have in mind (though i'm sure noone will enter haha)
Quote Originally Posted by B1ackAnge1 View Post
I think problems where you need to develop your own algorithm etc are always much more interesting. I may post a competition of my own for one I have in mind (though i'm sure noone will enter haha)
I just entered your competition ^^
though I'm sure I'm gonna fail at what we're going to do for the competition.
Fuck yeah! The demon is back!

<3 why06
Thanks. I just wanted something to do for C++ to test how much I need to learn and how much I already know. Practice using logic is good too.
Posts 1–11 of 11 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Talk with us