#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-O3")
#pragma GCC optimize("Ofast")
//#pragma GCC optimize("fast-math")
//#pragma GCC optimize("no-stack-protector")
#define F first
#define S second
#define sz(x) int(x.size())
#define pb push_back
#define N 100001
#define M ll(1e9 + 7)
#define inf 1e9 + 1e9
using namespace std;
//using namespace __gnu_pbds;
typedef long double ld;
typedef long long ll;
typedef short int si;
typedef array <int, 2> a2;
//typedef tree <int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
vector <pair <int, int> > g;
int main()
{
//freopen("input.txt", "r", stdin); //freopen("output4.txt", "w", stdout);
ios_base::sync_with_stdio(0); istream::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int n;
cin >> n;
g.resize(n);
for (int i = 0; i < n; i++)
{
int x;
cin >> x;
g[i] = {x, i};
}
sort(g.begin(), g.end());
int j = 1;
pair <int, int> ans[n];
for (int i = 0; i < n; i++)
{
while ((j + 1) * (j + 1) <= g[i].F) j++;
if (i != 0 && g[i].F == g[i - 1].F) ans[g[i].S] = ans[g[i - 1].S];
for (int u = 2; u <= j; u++)
if (g[i].F % u == 0 && __gcd(u + g[i].F / u, g[i].F) == 1) {ans[g[i].S] = {u, g[i].F / u}; break;}
if (ans[g[i].S].F == 0) ans[g[i].S] = {-1, -1};
}
for (int i = 0; i < n; i++) cout << ans[i].F << " "; cout << endl;
for (int i = 0; i < n; i++) cout << ans[i].S << " ";
}
Compilation message
pictionary.cpp: In function 'int main()':
pictionary.cpp:71:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
for (int i = 0; i < n; i++) cout << ans[i].F << " "; cout << endl;
^~~
pictionary.cpp:71:58: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
for (int i = 0; i < n; i++) cout << ans[i].F << " "; cout << endl;
^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
256 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
17 ms |
896 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
21 ms |
1152 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
30 ms |
1400 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
40 ms |
1784 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
51 ms |
2168 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
66 ms |
2680 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |