源代码:
/*********************************************************************
程序名:
版权: Copyright (c) 2024~9999 hdkghc
作者: hdkghc
日期: 2024-03-19 21:48
说明: This is a ___ program.
*********************************************************************/
#include <bits/stdc++.h>
#ifdef _LOCAL_TEST
#include<Windows.h>
#include<psapi.h>
#pragma comment(lib, "-lpsapi")
#endif
#define f1() for(int i = 1; i <= n; i++)
#define f2(i) for(int i = 1; i <= n; i++)
#define f3(i, from, to) for(int i = from; (from <= to) ? (i <= to) : (i >= to); i += (from <= to ? 1 : -1))
#define f4(i, from, to, step) for(int i = from; (from <= to) ? (i <= to) : (i >= to); i += (from <= to ? 1 : -1) * step)
#define f5(i, from, to, comp, cng) for(int i = from; comp(i, to); cng(i))
#define leq(tp) [](tp a, tp b) { return a <= b; }
#define geq(tp) [](tp a, tp b) { return a >= b; }
#define neq(tp) [](tp a, tp b) { return a != b; }
#define add1(tp) [](tp &a) { a++; }
#define nint ([]() -> long long { long long a; cin >> a; return a; }())
#define nstr ([]() -> string { string a; cin >> a; return a; }())
#define nline ([]() -> string { string a; getline(cin, a); return a; }())
#define next(type) ([]() -> type { type a; cin >> a; return a; }())
#define Y cout << "YES" << endl
#define N cout << "NO" << endl
#define YN(b) cout << ((b) ? "YES" : "NO") << endl
#define YNc(b) cout << ((b) ? "YES" : "NO") << endl; if(!(b)) continue
#define YNb(b) cout << ((b) ? "YES" : "NO") << endl; if(!(b)) break
#define NY(b) cout << (!(b) ? "YES" : "NO") << endl
#define NYc(b) cout << (!(b) ? "YES" : "NO") << endl; if(b) continue
#define NYb(b) cout << (!(b) ? "YES" : "NO") << endl; if(b) break
#define ensp " \n"[i == n]
#define enspc(i, n) " \n"[i == n]
#define enspb(boolean) " \n"[boolean]
#define l2r(i, l, r) for(int i = l; i <= r; i++)
#define r2l(i, l, r) for(int i = r; i >= l; i--)
using namespace std;
int _main();
#ifdef _LOCAL_TEST
int main()
{
string fn = (string)__FILE__ + (string)".out.txt";
system(((string)"type nul > \"" + fn + (string)"\"").data());
ofstream fout(fn);
streambuf *outbuf = cout.rdbuf();
cout.rdbuf(fout.rdbuf());
clock_t st = clock();
_main();
clock_t tim = clock() - st;
fout.close();
cout.rdbuf(outbuf);
cout << "----------\nExecute Time: " << (static_cast<double>(tim) / 1000.0) << endl;
PROCESS_MEMORY_COUNTERS pmc;
if (GetProcessMemoryInfo(GetCurrentProcess(), &pmc, sizeof(pmc)))
{
double s = pmc.WorkingSetSize;
printf("Memory Used: \n");
printf("\t %-20lf B\n", s);
s /= 1024;
printf("\t %-20lf KB\n", s);
s /= 1024;
printf("\t %-20lf MB\n", s);
s /= 1024;
printf("\t %-20lf GB\n", s);
s /= 1024;
printf("\t %-20lf TB\n", s);
}
system(("start notepad " + fn).data());
system("pause > nul");
return 0;
}
#elif defined(INTERACTIVE)
int main()
{
_main();
system("pause > nul");
return 0;
}
#else
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
_main();
return 0;
}
#endif
typedef vector<pair<long long, long long>> FACT;
typedef pair<long long, long long> FACTUNIT;
FACT Factor(long long n, long long *base_prod = NULL) // factorization
{
long long bp = 1;
FACT a;
a.clear();
for (int i = 2; i * i <= n; i++)
{
bool flag = 0;
int cnt = 0;
while (n % i == 0)
{
cnt++;
n /= i;
flag = 1;
}
if (flag)
{
bp *= i;
a.push_back(make_pair(i, cnt));
}
if (n == 1)
{
if(base_prod != NULL)
{
*base_prod = bp;
}
return a;
}
}
if (n > 1)
{
a.push_back(make_pair(n, 1));
bp *= n;
}
if(base_prod != NULL)
{
*base_prod = bp;
}
return a;
}
/////////////////////////////////////////////////////////////
int _main()
{
int t = nint;
while (t--)
{
pair<int, int> cnt[2] = {};
int n = nint, a[n + 1][n + 1] = {};
f1()
{
l2r(j, 1, n - 1)
{
a[i][j] = nint;
}
if(i == 1)
{
cnt[0] = make_pair(a[i][1], 1);
}
else if(a[i][1] != cnt[0].first)
{
cnt[1].first = a[i][1];
++cnt[1].second;
}
else
{
++cnt[0].second;
}
}
if(cnt[1].second != 1)
{
swap(cnt[0], cnt[1]);
}
cout << cnt[0].first << ' ';
f1()
{
if(a[i][1] == cnt[1].first)
{
l2r(j, 1, n - 1)
{
cout << a[i][j] << " \n"[j == n - 1];
}
break;
}
}
}
return 0;
}
编译信息:
g++.exe "D:\documents\C++ Program Path\CodeForces\CF1790C.cpp" -o "D:\documents\C++ Program Path\CodeForces\CF1790C.exe" -Os -m64 -std=gnu++11 -Wall -Wextra -pipe -I"C:\Program Files (x86)\Dev-Cpp\MinGW64\include" -I"C:\Program Files (x86)\Dev-Cpp\MinGW64\x86_64-w64-mingw32\include" -I"C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\8.1.0\include" -I"C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\8.1.0\include\c++" -L"C:\Program Files (x86)\Dev-Cpp\MinGW64\lib" -L"C:\Program Files (x86)\Dev-Cpp\MinGW64\x86_64-w64-mingw32\lib" -m64 -s
D:\documents\C++ Program Path\CodeForces\CF1790C.cpp:12: warning: ignoring #pragma comment [-Wunknown-pragmas]
#pragma comment(lib, "-lpsapi")
during RTL pass: expand
D:\documents\C++ Program Path\CodeForces\CF1790C.cpp: In function 'int _main()':
D:\documents\C++ Program Path\CodeForces\CF1790C.cpp:153:17: internal compiler error: in make_decl_rtl, at varasm.c:1322
int n = nint, a[n + 1][n + 1] = {};
^
libbacktrace could not find executable to open
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://sourceforge.net/projects/mingw-w64> for instructions.
附:代码模板没问题的