QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#117641#6568. Space Alignmentcada_dia_mas_insanos#WA 1ms3408kbC++171.8kb2023-07-01 21:23:082023-07-01 21:23:10

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-01 21:23:10]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3408kb
  • [2023-07-01 21:23:08]
  • 提交

answer

// Too many mind, no mind.
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
#include <array>
#include <iomanip>

using namespace std;

#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define COMP(x) sort(ALL(x)); x.resize(unique(ALL(x)) - (x).begin())
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)

using pii = pair <int, int>;
using vi = vector <int>;
using vpi = vector <pii>;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using ld = long double;
using vld = vector<ld>;

const int maxn = 1010;
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n; cin >> n;
	vector <string> a(n);
	vi tabs(n), spaces(n);
	string s;
	forn(i, n) {
		cin >> a[i];
		for(char& c : a[i]) {
			if (c == 's') spaces[i]++;
			else if (c == 't') tabs[i]++;
			else {
				assert(c == '}' || c ==  '{');
				s += c;
			}
		}
	}
	forn(it, maxn) {
		vi st;
		bool ok = 1;
		forn(i, n) {
			if (s[i] == '{') st.pb(i);
			else {
				int j = st.back();
				if (tabs[j]*it + spaces[j] == tabs[i]*it + spaces[i]) {
					st.pop_back();
				} else {
					ok = 0;
					break;
				}
			}
		}
		if (ok) {
			cout << it << endl;
			return 0;
		}
	}
	cout << -1 << endl;
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3408kb

input:

10
{
ss{
sts{
tt}
t}
t{
ss}
}
{
}

output:

2

result:

ok single line: '2'

Test #2:

score: -100
Wrong Answer
time: 1ms
memory: 3384kb

input:

2
{
}

output:

0

result:

wrong answer 1st lines differ - expected: '1', found: '0'