QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#792227 | #6568. Space Alignment | lukamosiashvili# | WA | 0ms | 3720kb | C++17 | 1.2kb | 2024-11-29 07:42:50 | 2024-11-29 07:42:50 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int inf = -999999999;
string s[109];
char ch[109];
int spaces[109], tabs[109], ans = inf;
int main(){
ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
int n;
cin >> n;
for(int i = 1; i <= n; i++){
cin >> s[i];
ch[i] = s[i].back();
}
for(int i = 2; i <= n; i++){
for(int j = 0; j < s[i].size() - 1; j++){
if(s[i][j] == 's') spaces[i]++; else tabs[i]++;
}
int j = i - 1;
if(ch[j] == '{' && ch[i] == '{') tabs[j]++;
if(ch[j] == '}' && ch[i] == '}') tabs[j]--;
if(spaces[j] == spaces[i] && tabs[j] == tabs[i]) continue;
if(spaces[j] == spaces[i] || tabs[j] == tabs[i]){
cout << -1;
return 0;
}
int b = tabs[i] - tabs[j], a = spaces[j] - spaces[i];
//cout << i << ": " << a << " " << b << " " << ans << endl;
if(a % b != 0){
cout << -1;
return 0;
}
int x = a / b;
if(ans != inf && ans != x){
cout << -1;
return 0;
}
ans = x;
}
if(ans <= 0) cout << -1; else cout << ans;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3592kb
input:
10 { ss{ sts{ tt} t} t{ ss} } { }
output:
2
result:
ok single line: '2'
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3720kb
input:
2 { }
output:
-1
result:
wrong answer 1st lines differ - expected: '1', found: '-1'