QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#117399 | #6568. Space Alignment | UNos_maricones# | AC ✓ | 3ms | 3492kb | C++20 | 1.4kb | 2023-07-01 04:40:23 | 2023-07-01 04:40:23 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "../debug.h"
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
#define pb push_back
int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
long long n; cin >> n;
long long curdep = 0;
vector <vector<long long>> eqs;
for (long long i = 0; i < n; ++i) {
string s; cin >> s;
// cout << s << endl;
long long nwtab = 0, nwdep = curdep, nwe = 0;
if (s.back() == '{') curdep++;
else curdep--, nwdep--;
for (long long j = 0; j + 1 < s.size(); ++j) {
if (s[j] == 't') nwtab++;
else nwe++;
}
eqs.pb({nwtab, nwdep, nwe});
}
for (long long i = 1; i <= 300000; ++i) {
long long impo = 0;
long long Ri = -1;
for (long long j = 0; j < n; ++j) {
long long posi = 0;
//cout << eqs[j][0] << ' ' << eqs[j][1] << ' ' << eqs[j][2] << '\n';
if (eqs[j][1] == 0) {
if (eqs[j][0] || eqs[j][2]) impo = 1;
}
else {
if ((i * eqs[j][0] + eqs[j][2]) % eqs[j][1]) impo = 1;
else {
posi = (i * eqs[j][0] + eqs[j][2]) / eqs[j][1];
if (Ri == -1) Ri = posi;
if (Ri != posi) impo = 1;
// cout << "in " << j << ' ' << posi << '\n';
}
}
}
//cout << Ri << '\n';
if (!impo) {
cout << i << '\n';
break;
}
if (i == 300000) cout << -1 << '\n';
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3468kb
input:
10 { ss{ sts{ tt} t} t{ ss} } { }
output:
2
result:
ok single line: '2'
Test #2:
score: 0
Accepted
time: 1ms
memory: 3412kb
input:
2 { }
output:
1
result:
ok single line: '1'
Test #3:
score: 0
Accepted
time: 1ms
memory: 3388kb
input:
4 { ss{ ss} }
output:
1
result:
ok single line: '1'
Test #4:
score: 0
Accepted
time: 1ms
memory: 3396kb
input:
4 { tt{ tt} }
output:
1
result:
ok single line: '1'
Test #5:
score: 0
Accepted
time: 1ms
memory: 3396kb
input:
4 { ss{ s} }
output:
-1
result:
ok single line: '-1'
Test #6:
score: 0
Accepted
time: 3ms
memory: 3416kb
input:
4 { tt{ t} }
output:
-1
result:
ok single line: '-1'
Test #7:
score: 0
Accepted
time: 3ms
memory: 3456kb
input:
4 { tt{ s} }
output:
-1
result:
ok single line: '-1'
Test #8:
score: 0
Accepted
time: 3ms
memory: 3416kb
input:
4 { tt{ sss} }
output:
-1
result:
ok single line: '-1'
Test #9:
score: 0
Accepted
time: 1ms
memory: 3472kb
input:
4 { tt{ ssss} }
output:
2
result:
ok single line: '2'
Test #10:
score: 0
Accepted
time: 1ms
memory: 3400kb
input:
6 { } { tt{ ssss} }
output:
2
result:
ok single line: '2'
Test #11:
score: 0
Accepted
time: 1ms
memory: 3432kb
input:
100 { } { } { t{ ssssssssssssssssssssssssssssssssssss} t{ t} t{ tssssssssssssssssssssssssssssssssssss{ tssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss{ tsssssssssssssssssssssssssssssssssssst} ttssssssssssssssssssssssssssssssssssss{ ssssssssssssssssssssssssssssssssssssssssss...
output:
36
result:
ok single line: '36'
Test #12:
score: 0
Accepted
time: 0ms
memory: 3412kb
input:
100 { t{ tssssssssssssssssssss{ ttssssssssssssssssssss{ tsssssssssssssssssssstt{ sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssstt{ ttsssssssssssssssssssstssssssssssssssssssssssssssssssssssssssss{ sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssstsssssssss...
output:
20
result:
ok single line: '20'
Test #13:
score: 0
Accepted
time: 1ms
memory: 3492kb
input:
4 { t{ sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss...
output:
999
result:
ok single line: '999'