ENG  RUSTimus Online Judge
Online Judge
Задачи
Авторы
Соревнования
О системе
Часто задаваемые вопросы
Новости сайта
Форум
Ссылки
Архив задач
Отправить на проверку
Состояние проверки
Руководство
Регистрация
Исправить данные
Рейтинг авторов
Текущее соревнование
Расписание
Прошедшие соревнования
Правила
вернуться в форум

Обсуждение задачи 1581. Работа в команде

ELDVN Whats the problem? WA #4 [1] // Задача 1581. Работа в команде 1 ноя 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;
}
ELDVN Re: Whats the problem? WA #4 // Задача 1581. Работа в команде 1 ноя 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;
}