QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#412993 | #6568. Space Alignment | Lspeed# | WA | 1ms | 3476kb | C++14 | 1.5kb | 2024-05-16 23:20:25 | 2024-05-16 23:20:27 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int,int>;
int main() {
// your code goes here
int n; cin>>n;
pii k[n];
int d[n];
int depth = 0;
for(int i=0;i<n;i++) {
string s; cin>>s;
// cout<<i<<s<<endl;
int a = 0, b = 0;
// cout<<s.size()<<'\n';
for(int j=0;j<s.size()-1;j++) {
// cout<<j<<'\n';
if(s[j] == 's')
a++;
else
b++;
}
// cout<<i<<s<<"WTF\n";
d[i] = depth;
k[i] = {a,b};
if(s[s.size()-1] == '{')
depth++;
else {
d[i]--;
depth--;
}
// cout<<i<<' '<<d[i]<<' '<<depth<<'\n';
}
// cout<<"YES\n";
int can = -10;
bool pass = false;
for(int i=0;i<n;i++) {
for(int j=0;j<i;j++) {
if(d[i] == -1 || d[j] == -1)
continue;
int aa = k[i].first * d[j], bb = k[i].second *d[j], cc = k[j].first*d[i], dd = k[j].second*d[i];
// cout<<i<<' '<<j<<' '<<aa<<' '<<bb<<' '<<cc<<' '<<dd<<' '<<can<<'\n';
if(bb == dd) {
if(aa == cc) {
continue;
}
else {
can = -1;
}
}
else if(aa == cc) {
if(bb == dd)
continue;
else
can = 0;
}
else {
if((abs(cc-aa))%(abs(bb-dd)) != 0) {
can = -1;
continue;
}
int new_can = (cc-aa)/(bb-dd);
// cout<<new_can<<endl;
if(can == -10) {
can = new_can;
}
else if(can != new_can) {
can = -1;
}
}
}
}
if(can == -10) can = 0;
cout<<can<<'\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: -100
Wrong Answer
time: 1ms
memory: 3476kb
input:
2 { }
output:
0
result:
wrong answer 1st lines differ - expected: '1', found: '0'