QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#188242#5420. InscryptionLilyWhiteCompile Error//C++142.4kb2023-09-25 17:15:292023-09-25 17:15:30

Judging History

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

  • [2023-09-25 17:15:30]
  • 评测
  • [2023-09-25 17:15:29]
  • 提交

answer

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;
using vpii = vector<pii>;
#define repn(i, n) for (int i = 1; i <= (int)n; i++)
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define repr(i, m, n) for (int i = (int)m; i <= (int)n; i++)
#define repd(i, m, n) for (int i = (int)m; i >= (int)n; i--)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#ifdef LILYWHITE
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) ;
#endif
const int __attribute__((unused)) INF = 0x3f3f3f3f;
template <typename T> inline T rd(T &x) {
	x = 0;
	T neg = 1;
	char c = 0;
	while (c < '0' || c > '9') {
		if (c == '-')
			neg = -1;
		c = getchar();
	}
	while (c >= '0' && c <= '9') {
		x = x * 10 + c - 48;
		c = getchar();
	}
	x *= neg;
	return x;
}
template <typename T, typename... Args> inline void rd(T &x, Args &...args) {
	rd(x);
	rd(args...);
}

int main() {
	int T;
	rd(T);
	while (T--) {
		int n;
		rd(n);
		int unused = 0;
		int sum = 1, cnt = 1;
		bool flag = 1;
		rep(i, n) {
			int x;
			rd(x);
            if (!flag) continue;
			if (x == -1) {
				if (cnt == 1) {
					if (unused) {
                    //    eprintf("Revert \n");
						unused--;
						sum++;
                        cnt++;
                    //    eprintf("to %d %d\n", sum, cnt);
                        continue;
					} else {
						cout << -1 << endl;
						flag = 0;
					}
				}
                cnt--;
			} else if (x == 0) {
                unused++;
                if (cnt == 1) {
                    unused--;
                    sum++;
                    cnt++;
                } else {
                    cnt--;
                }
            } else {
				sum++;
				cnt++;
			}
        //    cerr << sum << ' ' << cnt << endl;
		}
		if (flag) {
			cout << sum / gcd(sum, cnt) << ' ' << cnt / gcd(sum, cnt) << endl;
		}
	}
}

Details

answer.code: In function ‘int main()’:
answer.code:106:39: error: ‘gcd’ was not declared in this scope
  106 |                         cout << sum / gcd(sum, cnt) << ' ' << cnt / gcd(sum, cnt) << endl;
      |                                       ^~~