Problem:
ある学校で修学旅行へ行く計画がある.そのためにアンケート調査を行った.
生徒は 1 から
n
までの生徒番号を持ち,旅行候補の場所を 1 から
m
までの番号で表し,行きたい場所に ○,行きたくない場所に×の印をつけて提出している.
このとき, 行きたい場所の人数が多い順に,場所の番号を出力するプログラムを作成せよ.人数が同じときは,場所の番号順とする.
入力データ の 1 行目は生徒の人数
n
と旅行候補の場所の数
m
が空白で区切られ,
i
+ 1 行に生徒
i
のアンケート結果を ○ は 1 で×は 0 で表し,空白で区切られた
m
個の数字が並んでいる.1 ≤
n
≤ 1000, 1 ≤
m
≤ 100 とする.
入力例１
4 6
1 0 1 0 1 1
1 1 0 1 0 0
1 1 1 0 0 0
1 0 1 0 1 0
出力例１
1 3 2 5 4 6
入力
入力は複数のデータセットからなる．n, m がともに 0 のとき入力が終了する．データセットの数は 5 を超えない．
出力
データセットごとに、場所の番号 を１行に出力する．
入力例
4 6
1 0 1 0 1 1
1 1 0 1 0 0
1 1 1 0 0 0
1 0 1 0 1 0
4 6
1 0 1 0 1 1
1 1 0 1 0 0
1 1 1 0 0 0
1 0 1 0 1 0
0 0
出力例
1 3 2 5 4 6
1 3 2 5 4 6
上記問題文と自動審判に使われるデータは、
情報オリンピック日本委員会
が作成し公開している問題文と採点用テストデータです。

Submitted solutions:

code_snippet: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
#define all(A) A.begin(),A.end()
#define rep(i, n) for (ll i = 0; i < (ll) (n); i++)

int main() {
    
    ll N,M;
    while(cin>>N>>M){
        
    if(N+M==0)return 0;
    vector<pair<ll,ll>> P(M,{0,0});
    rep(i,M)P[i].second=-i;
    rep(i,N){
        rep(j,M){
            ll a;
            cin>>a;
            P[j].first+=a;
        }
    }
    sort(all(P));
    reverse(all(P));
    rep(i,M)cout<<-P[i].second+1<<" \n"[i==M-1];}
}
accuracy: 1
time_ms: 10
memory_kb: 3132
final_rank: 11

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



int main(){
    int flag=0;
    while(1){
        int n,m;
        cin >> n;
        if(cin.eof()){
            break;
        }
        cin >> m;
        if(flag){
            cout << endl;
        }
        flag =1;
        vector<int> data(m,0);
        for(int i=0;i<n;i++){
            for(int j=0;j<m;j++){
                int x;
                cin >> x;
                if(x){
                    data.at(j) += 1;
                }
            }
        }
        for(int i=0;i<m;i++){
            int max = 0, max_point = 0;
            for(int j=0;j<m;j++){
                if(data.at(j) > max){
                    max = data.at(j);
                    max_point = j;
                }
            }
            cout << max_point+1;
            data.at(max_point) = -1;
            if(i!=m-1){
                cout << " ";
            }
        }
    }

    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3400
final_rank: 17

code_snippet: #include<iostream>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>
#include<set>
#include<bitset>
#include<vector>
#include<string>
#include <iomanip>
#include <deque>
#include<list>
#include<cmath>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll=long long;
using P=pair<int,int>;
using P_S=pair<int,string>;
using P_D=pair<double,int>;
using T=tuple<int,int,char,ll,string>;

int main()
{
    int n,m;
    while(1){
        cin>>n>>m;
        if(n==0) break;
        vector<P>score(m);
        rep(i,m){
            score[i].first=0; score[i].second=-i-1;
        }
        rep(i,n){
            rep(j,m){
                int a;
                cin>>a;
                if(a==1) score[j].first++;
            }
        }
        sort(score.begin(),score.end());
        reverse(score.begin(),score.end());
        rep(i,m){
            if(i!=m-1)cout<<-1*score[i].second<<" ";
            else cout<<-1*score[i].second<<endl;
        }
    }
}
accuracy: 1
time_ms: 10
memory_kb: 3304
final_rank: 14

code_snippet: #include<iostream>
#include<algorithm>

using namespace std;

int main()
{
	while (true)
	{
		int n, m;
		cin >> n >> m;
		if (n == 0 && m == 0)
			break;
		int* counter = new int[m];
		fill(counter, counter + m, 0);
		int a;
		int* ans = new int[m];
		for (int i = 0; i < m; i++)
			ans[i] = i;
		for(int i = 0 ; i < n ; i++)
		{
			for (int j = 0; j < m; j++)
			{
				cin >> a;
				counter[j] += (a == 1);
			}
		}
		sort(ans, ans + m, [counter](int i1, int i2)->int {return counter[i1] > counter[i2] ||
			(counter[i1] == counter[i2] && i1 < i2) ? 1 : 0; });
		for (int i = 0; i < m - 1; i++)
			cout << ans[i] + 1 << ' ';
		cout << ans[m - 1] + 1 << endl;
	}	

	//system("pause");
}
accuracy: 1
time_ms: 10
memory_kb: 3112
final_rank: 10

code_snippet: #include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <cmath>
#include <bitset>
using namespace std;

bool larger(vector<int> x, vector<int> y){
	if(x[1] == y[1]){
		return x[0] < y[0];
	}
	else{
		return x[1] > y[1];
	}
}

int main(){
	int N, M;
	cin >> N >> M;
	while(N != 0){
		vector<vector<int> > result;
		for(int i = 0; i < M; i++){
			vector<int> v;
			v.push_back(i + 1);
			v.push_back(0);
			result.push_back(v);
		}
		for(int i = 0; i < N; i++){
			for(int j = 0; j < M; j++){
				int now;
				cin >> now;
				result[j][1] += now;
			}
		}
		sort(result.begin(), result.end(), larger);
		cout << result[0][0];
		for(int i = 1; i < M; i++){
			cout << " " << result[i][0];
		}
		cout << endl;
		cin >> N >> M;
	}
	return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3380
final_rank: 16

code_snippet: #include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int solve(){
    int n, m;
    cin >> n >> m;
    if(n == 0) return 0; 
    vector<int> cnt(m);
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            int x; cin >> x;
            cnt[j] += x;
        }
    }
    vector<int> ans(m);
    iota(ans.begin(),ans.end(), 0);
    stable_sort(ans.begin(),ans.end(), [&](int x, int y){ return cnt[x] > cnt[y]; });
    for (int i = 0; i < m; ++i) {
        if(i) printf(" ");
        printf("%d", ans[i]+1);
    }
    puts("");
    return 1;
}

int main() {
    while(solve());
    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3504
final_rank: 18

code_snippet: #include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>

using namespace std;

#define INF 10000000
#define MOD 1000000007
#define pi 3.14159265358979
//#define int long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define enld endl
//#define lint long long int

void vout(vector<int>A) {
	rep(i, A.size()) {
		cout << A[i];
		if (i == A.size() - 1) {
			cout << endl;
		}
		else {
			cout << ' ';
		}
	}
}

void vvout(vector<vector<int>>A) {
	rep(i, A.size()) {
		rep(j, A[i].size()) {
			cout << A[i][j];
			if (j == A[i].size() - 1) {
				cout << endl;
			}
			else {
				cout << ' ';
			}
		}
	}
}

int main() {
	int N, M;
	while (1) {
		cin >> N >> M;
		if (N == 0 && M == 0) {
			return 0;
		}
		vector<vector<int>>A(N, vector<int>(M));
		rep(i, N) {
			rep(j, M) {
				cin >> A[i][j];
			}
		}

		int cnt = 0;
		vector<pair<int, int>>V(M);
		rep(i, M) {
			rep(j, N) {
				if (A[j][i] == 1) {
					cnt++;
				}
			}
			V[i] = pair<int, int>(cnt, -1*(i + 1));
			cnt = 0;
		}
		sort(V);
		reverse(V);
		rep(i, M) {
			cout<<V[i].second* (-1);
			if (i == M - 1) {
				cout << enld;
			}
			else {
				cout << ' ';
			}
		}
	}
}
accuracy: 1
time_ms: 10
memory_kb: 3272
final_rank: 13

code_snippet: #include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<int, int>P;
int main() {
	int n, m; 
	while (cin >> n >> m, n) {
		P a[101];
		rep(i, n) {
			rep(j, m) {
				a[j].second = j + 1;
				int b; cin >> b;
				if (b)a[j].first--;
			}
		}sort(a, a + m);
		rep(i, m) {
			cout << a[i].second;
			if (i == m - 1)cout << endl;
			else cout << ' ';
		}
	}
	return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3084
final_rank: 8

code_snippet: #include <bits/stdc++.h>

using namespace std;

vector<pair<int, int> > CountOfPlace;

bool cmp(const pair<int, int> &p1, const pair<int, int> &p2) {
	if (p1.second == p2.second) {
		return p1.first < p2.first;
	}
	return p1.second > p2.second;
}

int main() {
	int n, m, num;
	vector<pair<int, int> >::iterator pos;

	while (cin >> n >> m, n) {
		CountOfPlace.clear();
		for (int j = 0; j < m; ++j) {
			CountOfPlace.push_back({ j,0 });
		}
		for (int i = 0; i < n; ++i) {
			for (int j = 0; j < m; ++j) {
				cin >> num;
				CountOfPlace[j].second += num;
			}
		}
		sort(CountOfPlace.begin(), CountOfPlace.end(), cmp);
		pos = CountOfPlace.begin();
		cout << pos->first + 1;
		while (++pos != CountOfPlace.end()) {
			cout << " " << pos->first + 1;
		}
		cout << endl;
	}
	
	return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3080
final_rank: 7

code_snippet: #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<61;
const ll mod=1e9+7;

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

int main(){
    int i,j;
    int n,m;
    while(1){
        cin>>n>>m;
        if(n==0) break;
        VI a(m);
        for(i=0;i<n;i++){
            for(j=0;j<m;j++){
                int x;
                cin>>x;
                a[j]+=x;
            }
        }
        vector<P> w;
        for(i=0;i<m;i++){
            w.pb(P(a[i],-i-1));
        }
        sort(w.begin(),w.end());
        reverse(w.begin(),w.end());
        for(i=0;i<m;i++) {
            cout<<-w[i].se;
            if(i!=m-1) cout<<" ";
        }
        cout<<endl;
    }


}
accuracy: 1
time_ms: 10
memory_kb: 3004
final_rank: 3

code_snippet: #include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int n, m;
  while (cin >> n >> m, n) {
    vector<pair<int, int>> vec(m);

    for (int i = 0; i < m; ++i)
      vec[i] = make_pair(i + 1, 0);

    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < m; ++j) {
        int tmp;
        cin >> tmp;
        vec[j].second += tmp;
      }
    }

    sort(vec.begin(), vec.end(), [](auto &a, auto &b) {
      return (a.second != b.second) ? a.second > b.second : a.first < b.first;
    });

    cout << vec[0].first;
    for (int i = 1; i < m; ++i)
      cout << " " << vec[i].first;
    cout << endl;
  }
}
accuracy: 1
time_ms: 10
memory_kb: 3092
final_rank: 9

code_snippet: #include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    int answer[5][100];
    int n,m;
    int k = 0;
    int am[5];
    while(cin >> n >> m){
        if(n == 0 && m == 0)break;
        am[k] = m;
        int a[1000][100];
        vector<int> s(m);
        vector<int> c(m);
        for(int i = 0;i < m;i++){
            s[i] = 0;
        }
        for(int i = 0;i < n;i++)for(int j = 0;j < m;j++){
            cin >> a[i][j];
            if(a[i][j] == 1)c[j] = s[j] = s[j] + 1;
            
        }
        
        sort(c.begin(),c.end());
        
        c.erase(unique(c.begin(),c.end()),c.end());
        
        reverse(c.begin(),c.end());
        
        
        int l = 0;
        for(int i = 0;i < c.size();i++){
            for(int j = 0;j < m;j++){
                if(s[j] == c[i]){
                    answer[k][l] = j;
                    l++;
                }
            }
        }
        k++;

    }
    for(int i = 0; i < k;i++){
        for(int j = 0;j < am[i];j++){
            cout << answer[i][j] + 1;
            if(j != am[i] - 1)cout << " ";
            else cout << endl;
        }
    }
    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3512
final_rank: 19

code_snippet: #include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
// #include <boost/foreach.hpp>
// #include <boost/range/algorithm.hpp>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define Sort(v) sort(all(v))
//#define INF 1e9
#define LINF 1e18
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
#define int long long
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};
// int dx[]={0,1,0,-1};
// int dy[]={1,0,-1,0};
//typedef pair<int,int> P;

const long long MOD=1000000007LL;
bool isupper(char c){if('A'<=c&&c<='Z')return 1;return 0;}
bool islower(char c){if('a'<=c&&c<='z')return 1;return 0;}
bool iskaibun(string s){for(int i=0;i<s.size()/2;i++)if(s[i]!=s[s.size()-i-1])return 0;return 1;}
bool isnumber(char c){return ('0'<=c&&c<='9');}
bool isalpha(char c){return (isupper(c)||islower(c));}
template<typename T> 
void print(vector<T> v){
    for(int i=0;i<v.size();i++){
        if(i)cout<<" ";
        cout<<v[i];
    }
    cout<<endl;
}
int INF=1e18;

template<typename T>
void printendl(vector<T> v){
    for(auto date:v)cout<<date<<endl;
}

template<typename T>
void printvv(vector<vector<T>> v){
    for(int i=0;i<v.size();i++){
        for(int j=0;j<v[i].size();j++){
            if(j)cout<<" ";
            cout<<v[i][j];
        }
        cout<<endl;
    }
}
int gcd(int a,int b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    else return gcd(b,a%b);
}

struct Edge{
    int to,cost;
};
struct S{
    int n,cost;
};

signed main (){
    int h,w;
    while(cin>>h>>w){
        if(w+h==0)break;
        vector<int> v(w,0);
        rep(i,0,h){
            rep(j,0,w){
                int x;cin>>x;
                v[j]+=x;
            }
        }

        vector<S> ans;
        rep(i,0,w){
            ans.push_back(S{i+1,v[i]});
        }
        sort(all(ans),[&](S a,S b){
            if(a.cost==b.cost)return a.n<b.n;
            else return a.cost>b.cost;
        });

        rep(i,0,w){
            if(i)cout<<" ";
            cout<<ans[i].n;
        }
        cout<<endl;
    }


    

    
    
}
/*

*/
accuracy: 1
time_ms: 10
memory_kb: 2992
final_rank: 2

code_snippet: #include <bits/stdc++.h>

#define REP(i,n) for (int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()

using namespace std;

using pii = pair<int, int>;

int main() {
    auto cmp = [](pii p1, pii p2) {
        return p1.first > p2.first || p1.first == p2.first && p1.second < p2.second;
    };
    while (true) {
        int n, m;
        cin >> n >> m;
        if (n == 0) {
            break;
        }
        vector<int> count(m);
        REP(i, n) {
            REP(j, m) {
                int x;
                cin >> x;
                count[j] += x;
            }
        }
        vector<pii> v(m);
        REP(i, m) v[i] = pii(count[i], i);
        sort(all(v), cmp);
        REP(i, m) {
            char c = (i == m - 1 ? '\n' : ' ');
            cout << v[i].second + 1 << c;
        }
    }
    cout << flush;
    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3036
final_rank: 6

code_snippet: #include <iostream>
#include <string>
#include <vector>

using namespace std;
int main(){
  int n,m;
  cin >> n >> m;
  while(n != 0 || m != 0){
    vector <vector<int> > nm(n,vector<int>(m,0));
    vector <int> cnt(m,0);
    for(int i = 0 ; i < n ; i++){
      for(int j = 0 ;j < m ; j++ ){
        cin >> nm[i][j];

        if(nm[i][j] == 1){
          cnt[j]++;
        }
      }
    }
    int spacecnt = 0;
    for(int i = n ; i >= 0 ; i--){
      for(int j = 0 ; j < m ; j++){

        if(cnt[j] == i){
          cout << j+1;
          spacecnt++;
          if(spacecnt < m){
            cout << " ";
          }
        }
      }
    }
    cout << endl;
    cin >> n >> m;
  }
  return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3336
final_rank: 15

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

int n,m;
pair<int,int> sum[101];

int main(){
	while(cin >> n >> m, n != 0){
		for(int i = 0; i < m; i++){
			sum[i].first = 0;
			sum[i].second = m-i;
		}
		for(int i = 0; i < n; i++){
			for(int j = 0; j < m; j++){
				int t;
				cin >> t;
				sum[j].first += t;
			}
		}
		sort(sum,sum+m,greater<pair<int,int> >());
		for(int i = 0; i < m; i++){
			if(i != 0){
				cout << " ";
			}
			cout << m - sum[i].second + 1;
		}
		cout << endl;
	}
	return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 2988
final_rank: 1

code_snippet: #include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
struct kkk
{
	int sc,s;
}ans[1010];
int comp(kkk a,kkk b)
{
	if(a.sc>b.sc)return 1;
	if(a.sc<b.sc)return 0;
	if(a.sc==b.sc)
	{
		if(a.s<b.s)return 1;
		else return 0;
	}
}
int main()
{
	int i,j,n,m,k;
	while(scanf("%d%d",&n,&m)&&n!=0&&m!=0)
	{
		memset(ans,0,sizeof(ans));
	for(i=1;i<=m;i++)
	{
		ans[i].s=i;
	}
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=m;j++)
		{
			cin>>k;
			ans[j].sc+=k;
		}
	}
	sort(ans+1,ans+1+m,comp);
	cout<<ans[1].s;
	for(i=2;i<=m;i++)
	{
		cout<<" "<<ans[i].s;
	}
	cout<<endl;
    }
	return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3212
final_rank: 12

code_snippet: #include<iostream>
using namespace std;

int main()
{
    int n, m, a, p[100], o[100];

    while( cin >> n >> m )
    {
        if( n == 0 && m == 0 )
            break;
        
        for( int i = 0; i < 100; i++ )
        {
            p[i] = 0;
            o[i] = i;
        }

        for( int i = 0; i < n; i++ )
            for( int j = 0; j < m; j++ )
            {
                cin >>  a;
                if( a == 1 )
                    p[j]++;
            }

        for( int i = 0; i < m; i++ )
            for( int j = 0; j < m - 1; j++ )
                if( p[j] < p[j+1] )
                {
                    int temp = p[j];
                    p[j] = p[j+1];
                    p[j+1] = temp;

                    temp = o[j];
                    o[j] = o[j+1];
                    o[j+1] = temp;
                }
        
        for( int i = 0; i < m - 1; i++ )
            cout << o[i] + 1 << " ";
        cout << o[m-1] + 1 << endl;
    }

    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3020
final_rank: 4

code_snippet: #include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
using namespace std;

int main(void){
  vector<pair<int, int> > cnt; // cnt[i] = {vote cnt, cand id}
  int n,m;
  
  while(true){
    cin >> n >> m;
    if (n==0 && m==0) break;
    cnt = vector<pair<int, int> >(m);
    for (int i=0; i<m; i++){
      cnt[i].first = 0;
      cnt[i].second = i+1;
    }
    for (int i=0; i<n; i++){
      for (int j=0; j<m; j++){
        int t;
        cin >> t;
        cnt[j].first -= t;
      }
    }
    stable_sort(cnt.begin(), cnt.end());
    cout << cnt[0].second;
    for (int i=1; i<m; i++){
      cout << " " << cnt[i].second;
    }
    cout << endl;
  }
  return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3032
final_rank: 5

code_snippet: #include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
using namespace std;
typedef pair<int,int> P;
double dat[100][100];
int dp[6][1010];//動的計画法
int prime[10000001];
char str[1010][1010];
vector<pair<int,int> > pc[100001];
int ABS(int a){return max(a,-a);}
int main(){
  int n,m,tmp;
  while(cin>>n>>m,n){
	  vector<pair<int,int> > place(m);
	  for(int i=0;i<m;i++) {
		 place[i].second = i+1;
		 place[i].first = 0;
	  }
	  for(int i=0;i<n;i++){
		  for(int j=0;j<m;j++){
			  cin>>tmp;
			  place[j].first -=tmp;
		  }
	  }
	  sort(place.begin(),place.end());
		for(int i=0;i<m;i++) cout<<(i?" ":"")<<place[i].second;
		cout<<endl;
  }
    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 5384
final_rank: 20