TopCoder

User's AC Ratio

97.8% (45/46)

Submission's AC Ratio

86.1% (93/108)

Tags

Description

以下乍看之下是一個把矩陣轉置以及各個元素加總之後輸出的程式碼,可是這份程式碼無法獲得 Accepted。請給出與以下的程式碼 edit distance 不超過 4,且能把矩陣轉置以及各個元素加總之後輸出並獲得 Accepted 的程式碼。

// =^● ⋏ ●^=
#include<bits/stdc++.h>
using namespace std;

int a[3636][3636];

int main(){
    int n; cin>>n;
    int sum=0;
    for(int i=0;i<n;++i){
        for(int j=0;j<n;++j){
            cin>>a[i][j];
            sum+=a[i][j];
        }
    }
    for(int i=0;i<n;++i){
        for(int j=0;j<n;++j){
            cout<<a[j][i]<<" ";
        }
        cout<<endl;
    }
    cout<<sum<<endl;
}

Input Format

第一行是一個正整數 $N$,代表矩陣的大小是 $N \times N$。
接下來的 $N$ 行每行有 $N$ 個數字,依序代表矩陣中的數字。
第 $i$ 行的第 $j$ 個數字是 $a _ {i,j}$。

  • $N \leq 3635$
  • $0 \leq a _ {i,j} < 100$

Output Format

前 $N$ 行請各輸出 $N$ 個數字,代表矩陣轉置後的結果。
最後一行請輸出一個數字,代表所有元素的加總。

Sample Input 1

3
1 2 3
4 5 6
7 8 9

Sample Output 1

1 4 7
2 5 8
3 6 9
45

Hints

Problem Source

Subtasks

No. Testdata Range Score
1 0 1

Testdata and Limits

No. Time Limit (ms) Memory Limit (VSS, KiB) Output Limit (KiB) Subtasks
0 5000 65536 262144 1