#include <bits/stdc++.h>
using namespace std;
vector<pair<int,int>> ed;
void display(int n)
{
int m=ed.size();
cout<<n<<' '<<m<<endl;
for (auto i:ed)
cout<<i.first<<' '<<i.second<<endl;
}
signed main()
{
int k;
cin>>k;
if (k>=0)
{
int n=k+3;
for (int i=2;i<n;i++)
{
ed.push_back({1,i});
ed.push_back({i,n});
}
display(n);
}
else
{
int a,b=-1;
for (int i=1;i<=100 && b==-1;i++)
for (int j=1;j<=100;j++)
if (j+i-1-i*j==k && j+i+i*j<=1000)
{
a=i,b=j;
break;
}
vector<pair<int,int>> ed;
int n=a+b+2;
for (int i=2;i<=2+a-1;i++)
{
ed.push_back({1,i});
for (int j=2+a;j<n;j++)
ed.push_back({i,j});
}
for (int i=2+a;i<n;i++)
ed.push_back({i,n});
display(n);
}
return 0;
}
Compilation message
konstrukcija.cpp: In function 'int main()':
konstrukcija.cpp:40:10: warning: 'a' may be used uninitialized in this function [-Wmaybe-uninitialized]
40 | int n=a+b+2;
| ~^~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Correct. |
2 |
Correct |
1 ms |
348 KB |
Correct. |
3 |
Correct |
1 ms |
348 KB |
Correct. |
4 |
Correct |
0 ms |
348 KB |
Correct. |
5 |
Correct |
1 ms |
348 KB |
Correct. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Wrong answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Correct. |
2 |
Correct |
1 ms |
348 KB |
Correct. |
3 |
Correct |
1 ms |
348 KB |
Correct. |
4 |
Correct |
0 ms |
348 KB |
Correct. |
5 |
Correct |
1 ms |
348 KB |
Correct. |
6 |
Incorrect |
1 ms |
348 KB |
Wrong answer. |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Correct. |
2 |
Correct |
1 ms |
348 KB |
Correct. |
3 |
Correct |
1 ms |
348 KB |
Correct. |
4 |
Correct |
0 ms |
348 KB |
Correct. |
5 |
Correct |
1 ms |
348 KB |
Correct. |
6 |
Incorrect |
1 ms |
348 KB |
Wrong answer. |
7 |
Halted |
0 ms |
0 KB |
- |