#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;
}
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:39:10: warning: 'a' may be used uninitialized in this function [-Wmaybe-uninitialized]
39 | int n=a+b+2;
| ~^~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Correct. |
2 |
Correct |
0 ms |
348 KB |
Correct. |
3 |
Correct |
1 ms |
344 KB |
Correct. |
4 |
Correct |
0 ms |
348 KB |
Correct. |
5 |
Correct |
1 ms |
348 KB |
Correct. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Correct. |
2 |
Correct |
1 ms |
348 KB |
Correct. |
3 |
Correct |
1 ms |
348 KB |
Correct. |
4 |
Correct |
1 ms |
344 KB |
Correct. |
5 |
Correct |
1 ms |
348 KB |
Correct. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Correct. |
2 |
Correct |
0 ms |
348 KB |
Correct. |
3 |
Correct |
1 ms |
344 KB |
Correct. |
4 |
Correct |
0 ms |
348 KB |
Correct. |
5 |
Correct |
1 ms |
348 KB |
Correct. |
6 |
Correct |
0 ms |
348 KB |
Correct. |
7 |
Correct |
1 ms |
348 KB |
Correct. |
8 |
Correct |
1 ms |
348 KB |
Correct. |
9 |
Correct |
1 ms |
344 KB |
Correct. |
10 |
Correct |
1 ms |
348 KB |
Correct. |
11 |
Incorrect |
11 ms |
604 KB |
Integer parameter [name=N] equals to 4877, violates the range [1, 1000] |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Correct. |
2 |
Correct |
0 ms |
348 KB |
Correct. |
3 |
Correct |
1 ms |
344 KB |
Correct. |
4 |
Correct |
0 ms |
348 KB |
Correct. |
5 |
Correct |
1 ms |
348 KB |
Correct. |
6 |
Correct |
0 ms |
348 KB |
Correct. |
7 |
Correct |
1 ms |
348 KB |
Correct. |
8 |
Correct |
1 ms |
348 KB |
Correct. |
9 |
Correct |
1 ms |
344 KB |
Correct. |
10 |
Correct |
1 ms |
348 KB |
Correct. |
11 |
Incorrect |
11 ms |
604 KB |
Integer parameter [name=N] equals to 4877, violates the range [1, 1000] |
12 |
Halted |
0 ms |
0 KB |
- |