#include <iostream>
#include <vector>
#pragma gcc optimize ("O3,unroll-loops")
using namespace std;
struct str
{
int index,a,b,c;
};
vector<str>vec;
int solve1()
{
for(auto j:vec)
{
// cout<<j.a<<" "<<j;
if(j.a==j.b && j.a==j.c)
{
return 1;
}
}
return 0;
}
int solve2()
{
int i,j,x1,x2,x3,x4;
for(i=0;i<vec.size();i++)
{
for(j=i+1;j<vec.size();j++)
{
x1=vec[i].b-vec[i].a;
x2=vec[i].c-vec[i].a;
x3=vec[j].b-vec[j].a;
x4=vec[j].c-vec[j].a;
if(x3*x1<0 && x4*x1==x3*x2)
{
return 1;
}
}
}
return 0;
}
int solve3()
{
int i,j,x1,x2,x3,x4,x5,x6,z,a,b,c;
for(i=0;i<vec.size();i++)
{
for(j=i+1;j<vec.size();j++)
{
for(z=j+1;z<vec.size();z++)
{
x1=vec[i].b-vec[i].a;
x2=vec[i].c-vec[i].a;
x3=vec[j].b-vec[j].a;
x4=vec[j].c-vec[j].a;
x5=vec[z].b-vec[z].a;
x6=vec[z].c-vec[z].a;
for(a=1;a<=60;a++)
{
for(b=1;b<=60;b++)
{
if(x5)
c=(-x1*a-x3*b)/x5;
else if(x6)
c=(-x2*a-x4*b)/x6;
if(x1*a+x3*b+x5*c==0 && x2*a+x4*b+x6*c==0 && c>=1)
return 1;
}
}
}
}
}
return 0;
}
int solve()
{
if(solve1()==1)
{
return 1;
}
if(solve2()==1)
{
return 2;
}
if(solve3()==1)
{
return 3;
}
return 0;
}
int main()
{
int n,i,j,k,cnt=0,a,b,c,a1,b1,c1;
cin>>a1>>b1>>c1;
cin>>n;
char tip;
for(i=1;i<=n;i++)
{
cin>>tip;
if(tip=='A')
{
cnt++;
cin>>a>>b>>c;
vec.push_back({cnt,a*b1*c1,b*a1*c1,c*b1*a1});
}
if(tip=='R')
{
cin>>a;
for(j=0;j<vec.size();j++)
{
if(vec[j].index==a)
{
vec.erase(vec.begin()+j);
break;
}
}
}
cout<<solve()<<'\n';
}
return 0;
}
Compilation message
Mixture.cpp:3: warning: ignoring '#pragma gcc optimize' [-Wunknown-pragmas]
3 | #pragma gcc optimize ("O3,unroll-loops")
|
Mixture.cpp: In function 'int solve2()':
Mixture.cpp:25:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<str>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
25 | for(i=0;i<vec.size();i++)
| ~^~~~~~~~~~~
Mixture.cpp:27:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<str>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
27 | for(j=i+1;j<vec.size();j++)
| ~^~~~~~~~~~~
Mixture.cpp: In function 'int solve3()':
Mixture.cpp:44:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<str>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
44 | for(i=0;i<vec.size();i++)
| ~^~~~~~~~~~~
Mixture.cpp:46:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<str>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
46 | for(j=i+1;j<vec.size();j++)
| ~^~~~~~~~~~~
Mixture.cpp:48:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<str>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
48 | for(z=j+1;z<vec.size();z++)
| ~^~~~~~~~~~~
Mixture.cpp: In function 'int main()':
Mixture.cpp:107:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<str>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
107 | for(j=0;j<vec.size();j++)
| ~^~~~~~~~~~~
Mixture.cpp:91:19: warning: unused variable 'k' [-Wunused-variable]
91 | int n,i,j,k,cnt=0,a,b,c,a1,b1,c1;
| ^
Mixture.cpp: In function 'int solve3()':
Mixture.cpp:64:71: warning: 'c' may be used uninitialized in this function [-Wmaybe-uninitialized]
64 | if(x1*a+x3*b+x5*c==0 && x2*a+x4*b+x6*c==0 && c>=1)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
97 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
3 ms |
348 KB |
Output is correct |
6 |
Correct |
7 ms |
348 KB |
Output is correct |
7 |
Execution timed out |
2065 ms |
596 KB |
Time limit exceeded |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
97 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
3 ms |
348 KB |
Output is correct |
6 |
Correct |
7 ms |
348 KB |
Output is correct |
7 |
Execution timed out |
2065 ms |
596 KB |
Time limit exceeded |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
97 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
3 ms |
348 KB |
Output is correct |
6 |
Correct |
7 ms |
348 KB |
Output is correct |
7 |
Execution timed out |
2065 ms |
596 KB |
Time limit exceeded |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
97 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
3 ms |
348 KB |
Output is correct |
6 |
Correct |
7 ms |
348 KB |
Output is correct |
7 |
Execution timed out |
2065 ms |
596 KB |
Time limit exceeded |
8 |
Halted |
0 ms |
0 KB |
- |