QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#179947#7240. ABBAxaphoenix#WA 1ms3716kbC++141.5kb2023-09-15 13:50:282023-09-15 13:50:29

Judging History

你现在查看的是最新测评结果

  • [2023-09-15 13:50:29]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3716kb
  • [2023-09-15 13:50:28]
  • 提交

answer

#include<bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pf push_front
#define LC k<<1
#define RC k<<1|1
#define IO cin.sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repn(i, a, n) for (int i = a; i <= n; i++)
#define per(i, a, n) for (int i = (n) - 1; i >= a; i--)
#define pern(i, a, n) for (int i = n; i >= a; i--)

typedef long long LL;
typedef long double LD;
typedef unsigned long long ull;
typedef pair<int, int> PII;
typedef pair<int, LL> PIL;
typedef pair<LL, int> PLI;
typedef pair<double, double> PDD;
typedef pair<ull, ull> PUU;
typedef pair<LL, LL> PLL;

const int N = 210;
const int M = 1100000;
const int mod = 1e9+7;
const int inf = (int)1e9;
const LL INF = 1e18;
const double eps = 1e-10;

mt19937_64 Rand((unsigned long long)new char);
#define rand Rand

int n, m, ans, pp[N];
LD a[N][N];
int main() {
	IO;
	cin >> n >> m;
	repn(i, 1, n) repn(j, 1, m) cin >> a[i][j];
	n = max(n, m);
	repn(i, 1, n) {
		int pos = -1;
		repn(j, 1, n) if (abs(a[j][i]) > eps && !pp[j]) {
			pos = j;
			break;
		}
		if (pos == -1) continue;
		repn(j, 1, n) swap(a[i][j], a[pos][j]);
		pp[i] = 1, ans++;
		LD d = 1.0 / a[i][i];
		repn(j, 1, n) a[i][j] *= d;
		repn(j, 1, n) if (i != j) {
			LD coef = a[j][i];
			repn(k, 1, n) a[j][k] -= coef * a[i][k];
		}
	}
	cout << ans << "\n";
			
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3592kb

input:

3 5
1 2 3 4 5
2 4 6 8 10
3 6 9 12 15

output:

1

result:

ok 1 number(s): "1"

Test #2:

score: 0
Accepted
time: 1ms
memory: 3596kb

input:

3 3
2 0 2
0 2 0
2 0 2

output:

2

result:

ok 1 number(s): "2"

Test #3:

score: 0
Accepted
time: 0ms
memory: 3600kb

input:

1 1
100

output:

1

result:

ok 1 number(s): "1"

Test #4:

score: 0
Accepted
time: 1ms
memory: 3660kb

input:

2 2
1 1
1 1

output:

1

result:

ok 1 number(s): "1"

Test #5:

score: 0
Accepted
time: 1ms
memory: 3716kb

input:

2 2
1 1
1 2

output:

2

result:

ok 1 number(s): "2"

Test #6:

score: 0
Accepted
time: 1ms
memory: 3652kb

input:

2 3
0 0 0
0 0 0

output:

0

result:

ok 1 number(s): "0"

Test #7:

score: -100
Wrong Answer
time: 0ms
memory: 3712kb

input:

20 20
1149 -158289 421301 -625382 639638 -312855 442515 -223152 -686926 394334 -746085 -488817 -124299 -137253 215418 -120343 632332 845498 -820913 -770155
216423 -11638 -824453 -329865 -799994 166256 164729 -811228 -477642 312149 -570809 -267741 849126 749161 600137 141212 642385 -310587 412930 -22...

output:

13

result:

wrong answer 1st numbers differ - expected: '10', found: '13'