ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1581. Teamwork

Whats the problem? WA #4
Posted by ELDVN 1 Nov 2015 14:16
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <iomanip>

#define F first
#define S second
#define ll long long
#define len length()
#define sqr(x) x*x
#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define bp(x) __builtin_popcount(x)
#define INF numeric_limits<long long int>::max()
#define frp freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++)

const int maxn = (int)1e6;
const int mod = (int)1e9 + 7;

using namespace std;

int n;
int a[1010];

main(){
    scanf("%d",&n);
    for(int i=1; i <= n; i++){
        int x; scanf("%d",&x);
        a[x]++;
    }
    for(int i=0; i <= 10; i++){
        if(a[i] > 0)
            printf("%d %d ",a[i], i);
    }


    return 0;
}
Re: Whats the problem? WA #4
Posted by ELDVN 1 Nov 2015 14:28
I write the same logic, but first my code got WA #4. Second is accept! Wtf ? :D
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <iomanip>

#define F first
#define S second
#define ll long long
#define len length()
#define sqr(x) x*x
#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define bp(x) __builtin_popcount(x)
#define INF numeric_limits<long long int>::max()
#define frp freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++)

const int maxn = (int)1e6;
const int mod = (int)1e9 + 7;

using namespace std;

int n;
int cnt=1,ans;
int a[1010];

main(){
    scanf("%d",&n);
    for(int i=1; i <= n; i++){
        scanf("%d",&a[i]);
    }
    for(int i=1; i <= n; i++){
        if(a[i]==a[i+1]){
            cnt++;
            ans=a[i+1];
        }
        else{
            ans=a[i];
            printf("%d %d ",cnt,ans);
            cnt=1;
        }
    }


    return 0;
}