Browsed by
Category: Uncategorized

Code Knights Round 10 Results and Problem Analysis ?>

Code Knights Round 10 Results and Problem Analysis

Problem A’s Solution by Amjad:

#include <iostream>
using namespace std;
int n ;
int tmp;
int tallest = 1 ; 
int shortest = (1<<31)-1;
int main(){
    cin >> n ; 
    for(int i=0;i<n;i++){
        cin >> tmp;
        if ( tmp > tallest ) tallest = tmp;
        if ( tmp < shortest ) shortest = tmp;
    }
    cout << tallest << " " << shortest << endl;
    return 0;
}

Problem B’s Solution by Amjad:

#include <iostream>
#include <algorithm>
using namespace std;
int n ;
int a[1000001];
int main(){
    cin >> n ; 
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    sort(a,a+n);
    reverse(a,a+n);
    cout << a[0];
    for(int i=1;i<n;i++){
        cout << " " << a[i];
    }
    cout << endl;
    return 0;
}

Problem C’s Solution by Asyraf:

#include<bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef pair<ll,ll> pii;
#define REP(i,n) for(ll i=0;i<n;i++)

#ifdef DEBUG
#define dbg(x) x
#define dbgp(x) cerr << x << endl;
#else
#define dbg(x) //x
#define dbgp(x) //cerr << x << endl;
#endif

int main(){
    int n;
    cin >> n;
    set<int> graph[n];

    REP(i, n){
        int c;
        cin >> c;
        REP(j, c){
            int d;
            cin >> d;
            d--;
            graph[i].insert(d);
        }
    }

    int k;
    cin >> k;
    vector<int> instructions;
    REP(i, k){
        int d;
        cin >> d;
        d--;
        instructions.push_back(d);
    }

    bool valid = true;
    int cur = instructions[0];
    for(int i=1;i<instructions.size();i++){
        int next = instructions[i];
        if(graph[cur].find(next) == graph[cur].end() && next != cur){
            valid = false;
            break;
        }
        cur = next;
    }

    if(valid){
        cout << "Instruction is OK" << endl;
    }else{
        cout << "This instruction will lead you astray" << endl;
    }

}

Problem D’s Solution by Zarir:

#include <iostream>

using namespace std;

#define ll long long
#define MX 20

ll fact[MX+1];

int main(){
	fact[0]=1;
	for(int i=1;i<=MX;i++) fact[i] = fact[i-1]*i;
	int k,n,q;
	cin>>k>>n>>q;
	int pk;
	ll co;
	while(q--){
		co = fact[n];
		for(int i=0;i<k;i++){
			cin>>pk;
			co /= fact[pk];
		}
		cout<<co<<endl;
	}
	return 0;
}

Problem E’s Solution by Ayesha:

#include <bits/stdc++.h>
using namespace std;

int main(){
	int t, n = 12, input;
	int de[100], f[100];
	de[0] = 1;
	f[0] = 1;
	de[1] = 0;
	f[1] = 1;
	for(int i=2 ; i<=n; i++){
		de[i] = (i-1) * (de[i-1]+de[i-2]);
		f[i] = f[i-1]*i;
	}
	cin >> t;
	while(t--){
		cin >> input;
		cout << de[input] << "/" << f[input] << endl;
	}
	return 0;
} 
Code Knights Round 10 ?>

Code Knights Round 10

Assalamualaikum everyone,

This is an announcement for Code Knights Round 10. If this is the first time you heard of Code Knights, please checkout this link. The short version is that, we are organizing a competitive programming rounds every two weeks open to all Malaysian university student. We do this for practice, education and mostly for the fun of it.

The competition will be held online, similar with various other competitive programming platform such as codeforces and hackerearth, except the difficulty is tuned down to cater for beginner. You can use C, C++, Python or Java. There will be 5 problem to be solved with varying difficulty.

Date: 5th November 2016
Time: 8PM to 12 AM Malaysian Time
Venue: Online (Link will be given later)
Registration fees: * FREE *
Registration link for DSA students: https://goo.gl/forms/pecD8HUbhsSAta6B2
Registration link: http://goo.gl/forms/VJFvSmekoH2Uox203
Feedback form: https://goo.gl/forms/Mm1yGOM3dL8hWY0w1

If you want to participate in Code Knights, please fill up your details in the google forms link above. Register once, and you will be registered for all future rounds. We will remind you on the rounds through emails and whatsapp group. Please register before 6 pm on the day of the competition as I have to input your login information into the system. If you have any question, feel free to comment down below.

Code Knights Round 9 ?>

Code Knights Round 9

Assalamualaikum everyone,

This is an announcement for Code Knights Round 9. If this is the first time you heard of Code Knights, please checkout this link. The short version is that, we are organizing a competitive programming rounds every two weeks open to all Malaysian university student. We do this for practice, education and mostly for the fun of it.

The competition will be held online, similar with various other competitive programming platform such as codeforces and hackerearth, except the difficulty is tuned down to cater for beginner. You can use C, C++, Python or Java. There will be 5 problem to be solved with varying difficulty.

Date: 15th October 2016
Time: 8PM to 12 AM Malaysian Time
Venue: Online (Link will be given later)
Registration fees: * FREE *
Registration link for DSA students: https://goo.gl/forms/pecD8HUbhsSAta6B2
Registration link: http://goo.gl/forms/VJFvSmekoH2Uox203
Feedback form: https://goo.gl/forms/Mm1yGOM3dL8hWY0w1

If you want to participate in Code Knights, please fill up your details in the google forms link above. Register once, and you will be registered for all future rounds. We will remind you on the rounds through emails and whatsapp group. Please register before 6 pm on the day of the competition as I have to input your login information into the system. If you have any question, feel free to comment down below.

Code Knights Round 7 Results and Problem Analysis ?>

Code Knights Round 7 Results and Problem Analysis

Assalamualaikum everyone,

Last Saturday, the 7th round of Code Knights was held, with a total of….. 12 participants. The problems of this round are prepared without proper care due to last minute changes in internal schedule (Eidul Adha specifically). I am not quite sure how to classify this last round. Anyways, we move on and hopefully prepare better ones in the future.

screenshot-from-2016-09-16-183548
Here you go 12 participants and the winner is anas_95.

How hard? Well.. I don’t know. The winner for this round goes to anas_95 from IIUM, who also won last round. anas_95 was the only participant who manage to solve 4 problems, but he did not solve problem D. It’s nice to see someone from IIUM winning again, but its starting to get boring. Can someone else win next time? stdLn maybe? Heck, I’m even waiting for lim2481284 to make a comeback.

Read More Read More

Code Knights Round 8 ?>

Code Knights Round 8

Assalamualaikum everyone,

This is an announcement for Code Knights Round 8. If this is the first time you heard of Code Knights, please checkout this link. The short version is that, we are organizing a competitive programming rounds every two weeks open to all Malaysian university student. We do this for practice, education and mostly for the fun of it.

The competition will be held online, similar with various other competitive programming platform such as codeforces and hackerearth, except the difficulty is tuned down to cater for beginner. You can use C, C++, Python or Java. There will be 5 problem to be solved with varying difficulty.

Date: 24th September 2016
Time: 8PM to 12 AM Malaysian Time
Venue: Online (Link will be given later)
Registration fees: * FREE *
Registration link for DSA students: https://goo.gl/forms/pecD8HUbhsSAta6B2
Registration link: http://goo.gl/forms/VJFvSmekoH2Uox203
Feedback form: https://goo.gl/forms/Mm1yGOM3dL8hWY0w1

If you want to participate in Code Knights, please fill up your details in the google forms link above. Register once, and you will be registered for all future rounds. We will remind you on the rounds through emails and whatsapp group. Please register before 6 pm on the day of the competition as I have to input your login information into the system. If you have any question, feel free to comment down below.