QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#130882#6669. MapaWilliams0 6ms3568kbC++143.2kb2023-07-25 16:30:462023-07-25 16:30:48

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-25 16:30:48]
  • 评测
  • 测评结果:0
  • 用时:6ms
  • 内存:3568kb
  • [2023-07-25 16:30:46]
  • 提交

answer

#include <bits/stdc++.h>
#define for_(i,a,b) for (int i = (a); i < (b); i++)
#define rep_(i,a,b) for (int i = (a); i <= (b); i++)
#define per_(i,a,b) for (int i = (a); i >= (b); i--)
#define pii pair<int, int>
#define pll pair<ll, ll> 
#define fi first
#define se second
#define ll long long
#define sz(a) (int)a.size()
#define all(v) v.begin(), v.end()
#define clr(x) memset(x, 0, sizeof(x))
#define ull unsigned long long
#define pb push_back
#define DEBUG(x) cerr << #x << '=' << x << endl
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"]=";rep_(_x,(L),(R))cerr<<a[_x]<<" "; cerr<<endl; 
	#ifdef LOCAL
#define line cout << "--------------------------------" << endl;
#define CE cout << endl;
#define CO cout << "OK" << endl;
#define D DEBUG
    #endif
#define endl '\n'
#define int long long
using namespace std;
bool be;clock_t startTime;
double getCurrentTime() {
	return (double)(clock() - startTime) / CLOCKS_PER_SEC;
}
const int maxn = 2e5 + 10, mod = 998244353;// mod = 1949777;
const double EPS = 1e-3;
int n, m;
int a[maxn], b[maxn];
bool ed;

ll Get(int a, int b) {
	a %= mod;
	ll ans = 1; 
	while(b) {
		if (b & 1) ans = ans * a % mod;
		b >>= 1;
		a = a * a % mod;
	}
	return ans;
}
int c[105][105], d[105]; 
void Gaosi(int x) {
	if (x == n + 1) return;
	for (int i = x; i <= n; i++) {
		if (c[i][x]) {
			swap(c[i], c[x]);
			swap(b[i], b[x]);
			break;
		}
	}
	for (int i = 1; i <= n; i++) {
		if (i == x) continue;
		int inv = c[i][x] * Get(c[x][x], mod - 2) % mod;
		for (int j = 1; j <= n; j++) {
			c[i][j] = c[i][j] - inv * c[x][j] % mod;
			c[i][j] %= mod;
		}
		b[i] -= inv * b[x] % mod; b[i] %= mod;
	}
	Gaosi(x + 1);
	return;
}
void solve1() {
	cin >> n;
	rep_(i, 1, n) {
		cin >> a[i] >> b[i];
		rep_(j, 1, n) c[i][j] = Get(a[i], j);
	}
	Gaosi(1);
	cout << n * 30 << endl;
	rep_(i, 1, n) {
		b[i] = b[i] * Get(c[i][i], mod - 2) % mod;
		c[i][i] = 1;
		b[i] = (b[i] + mod) % mod;
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j <= 30; j++) {
			cout << (b[i] >> j & 1);
		}
	}
	cout << endl;
//	rep_(i, 1, n){
//		rep_(j, 1, n) {
//			cout << c[i][j] << ' ';
//		}
//		cout << b[i]; 
//		cout << endl;
//	}
}
int k;
void solve2() {
	cin >> n >> k >> m;
	rep_(i, 1, n) {
		char c;
		d[i] = 0;
		int p = 1;
		for (int j = 0; j <= 30; j++) {
			cin >> c;
			d[i] = d[i] + (c - '0') * p;
			p <<= 1;
		}
	}
	rep_(i, 1, k) {
		int x; cin >> x;
		int y = 0;
		rep_(j, 1, n) {
			y = y + Get(x, j) * d[j] % mod;
			y %= mod;
		}
		cout << y << endl;
	}
}
signed main() {
	#ifdef LOCAL
		freopen("w.in", "r", stdin);
//		freopen("w.out", "w", stdout);
		startTime = clock();
//		time_t now_time = time(NULL); tm* TuT = localtime(&now_time); cout << asctime(TuT); cout << "CodeBegin:_______________________" << endl;
//		cout << "Memory footprint:" << ((&be - &ed) >> 20) <<"MB"<< endl;
//		line;
	#endif
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
  //int tt; cin >> tt; while(tt--) solve();
  	int T;
  	cin >> T;
  	if (T == 1) {
  		solve1();
	  } 
	else
	solve2();
  	#ifdef LOCAL
  	cerr<<"\n\n-----------------------\nProgram done in "<<clock()-startTime<<" ms";
	#endif
 	return 0; 
}
//by whc
// check if over int , and open long long !!!

// 

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 6ms = 5ms + 1ms
memory: 3568kb,3412kb

input:

1
100
495528311 963488152
269613430 443544124
700489871 792354118
151890319 506569919
180452297 13229948
684464994 543841485
978085128 903812192
238355172 441140842
28061035 783291471
530823766 718942732
936853023 439421263
201361623 226633955
304644844 778868118
864860135 461524170
88300500 6959354...

output:

3000
0111111110100110110010001100110110011010110100111010110110101000100001010111001011111101011101011101000101011111100101001000011111110011110001101010000001001000100100001011101110011100101000110001011010100100110100110001010011111011111011101000010000001000011001000000111101011101000011001000110...

input:

Invalid Output on Phase 1

output:


result:

FAIL Unexpected end of file - int32 expected (/opt/uoj/judger/uoj_judger/work/answer.txt)