QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#524636 | #6568. Space Alignment | amirreza# | AC ✓ | 1ms | 3808kb | C++20 | 2.3kb | 2024-08-19 21:56:02 | 2024-08-19 21:56:02 |
Judging History
answer
// ki bood ke goft Ghatinga?
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<pii,int> ppiii;
// vectors and Sets:
#define vc vector
#define pb push_back
#define all(c) (c).begin(), (c).end()
// pairs
#define mp make_pair
#define fr first
#define sc second
// execution time check and Debug
#define StartEX clock_t startExeTime = clock();
#define EndEX clock_t endExeTime = clock();
#define ExTime cerr << "\nTotal Execution Time is: " << double(-double(startExeTime)+double(endExeTime)) / CLOCKS_PER_SEC;
#define debug(x) cerr << #x << " : " << x << '\n'
#define endl "\n"
// time optimization
#define Heh ios::sync_with_stdio(false);cin.tie(0);
#define Bah ios::sync_with_stdio(false);
#pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
// useful functions
ll pw(ll a,ll b){
ll ret = 1;
ll mul = a;
while(b > 0){
if(b&1)
ret = (ret * mul);
mul = (mul * mul);
b >>= 1;
}
return ret;
}
ll pw(ll a,ll b,ll mod){
ll ret = 1;
ll mul = a;
while(b > 0){
if(b&1)
ret = (ret * mul) % mod;
mul = (mul * mul) % mod;
b >>= 1;
}
return ret;
}
ll to_int(string s){
ll ret = 0;
for(int i = 0 ; i < (int)s.size() ; i++) ret = 10 * ret + s[i] - '0';
return ret;
}
bool deq(ld a , ld b){return (abs(a-b) < 0.000001);} // 10 ^ -6
const int MAXP = 1e6 + 16;
int main()
{
int n;
cin >> n;
string s[n];
for(int i = 0 ; i < n ; i++) cin >> s[i];
for(int t = 1 ; t <= 1001 ; t++){
int k = 0;
int ii = -2;
for(int i = 0 ; i < n ; i++){
if(s[i].back() == '}') k--;
int ci = 0;
for(char ch : s[i]){
if(ch == 't') ci += t;
if(ch == 's') ci += 1;
}
if(k == 0 and ci > 0){
ii = -1;
break;
}
else if(k == 0 and ci == 0){
}
else if(ci == 0){
ii = -1;
break;
}
else if(ci % k > 0 or (ii != -2 and ii != ci / k)){
ii = -1;
break;
}
if(k > 0) ii = ci / k;
if(s[i].back() == '{') k++;
}
if(ii != -1){
cout << t << endl;
return 0;
}
}
cout << -1 << endl;
}
// ki seda kard Patinga?
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3600kb
input:
10 { ss{ sts{ tt} t} t{ ss} } { }
output:
2
result:
ok single line: '2'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3808kb
input:
2 { }
output:
1
result:
ok single line: '1'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3572kb
input:
4 { ss{ ss} }
output:
1
result:
ok single line: '1'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3764kb
input:
4 { tt{ tt} }
output:
1
result:
ok single line: '1'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3768kb
input:
4 { ss{ s} }
output:
-1
result:
ok single line: '-1'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3468kb
input:
4 { tt{ t} }
output:
-1
result:
ok single line: '-1'
Test #7:
score: 0
Accepted
time: 0ms
memory: 3592kb
input:
4 { tt{ s} }
output:
-1
result:
ok single line: '-1'
Test #8:
score: 0
Accepted
time: 0ms
memory: 3464kb
input:
4 { tt{ sss} }
output:
-1
result:
ok single line: '-1'
Test #9:
score: 0
Accepted
time: 0ms
memory: 3808kb
input:
4 { tt{ ssss} }
output:
2
result:
ok single line: '2'
Test #10:
score: 0
Accepted
time: 0ms
memory: 3572kb
input:
6 { } { tt{ ssss} }
output:
2
result:
ok single line: '2'
Test #11:
score: 0
Accepted
time: 0ms
memory: 3584kb
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: 1ms
memory: 3612kb
input:
100 { t{ tssssssssssssssssssss{ ttssssssssssssssssssss{ tsssssssssssssssssssstt{ sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssstt{ ttsssssssssssssssssssstssssssssssssssssssssssssssssssssssssssss{ sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssstsssssssss...
output:
20
result:
ok single line: '20'
Test #13:
score: 0
Accepted
time: 0ms
memory: 3736kb
input:
4 { t{ sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss...
output:
999
result:
ok single line: '999'