Thu, 09 May 2019 18:40:22 +0800

master
大蒟蒻 7 years ago
parent 710b1bebcd
commit c4ceda5a02

@ -0,0 +1,11 @@
cmake_minimum_required(VERSION 3.0)
set(CMAKE_CXX_STANDARD 17)
if(MSVC)
add_compile_options("/Zc:__cplusplus")
endif()
include_directories("D:\\PortableApps\\MSYS2\\mingw64\\include\\c++\\8.3.0\\x86_64-w64-mingw32")
add_executable(P1 P1.cpp)
add_executable(P2 P2.cpp)
add_executable(P3 P3.cpp)
add_executable(P4 P4.cpp)
add_executable(P5 P5.cpp)

@ -0,0 +1,22 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n, h, m;
int v[1000];
scanf("%d%d%d", &n, &h, &m);
for (int i = 1; i <= n; i++) v[i] = h;
for (int i = 0; i < m; i++)
{
int l, r, x;
scanf("%d%d%d", &l, &r, &x);
for (int j = l; j <= r; j++)
v[j] = min(v[j], x);
}
long long ans = 0;
for (int i = 1; i <= n; i++) ans += 1ll * v[i] * v[i];
printf("%lld", ans);
return 0;
}

@ -0,0 +1,32 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
int a[60][60], b[60][60];
void die(int v)
{
puts(v ? "Possible" : "Impossible");
exit(0);
}
int main()
{
int n, m;
scanf("%d%d", &n, &m);
for (int i = 1; i <= n; i++)
for (int j = 1; j <= m; j++)
scanf("%d", &a[i][j]);
for (int i = 1; i <= n; i++)
for (int j = 1; j <= m; j++)
scanf("%d", &b[i][j]);
for (int i = 1; i <= n; i++)
for (int j = 1; j <= m; j++)
if (a[i][j] > b[i][j])
swap(a[i][j], b[i][j]);
for (int i = 1; i <= n; i++)
for (int j = 1; j <= m; j++)
if (a[i - 1][j] >= a[i][j] || a[i][j - 1] >= a[i][j] ||
b[i - 1][j] >= b[i][j] || b[i][j - 1] >= b[i][j])
die(0);
die(1);
return 0;
}

@ -0,0 +1,8 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
int main()
{
return 0;
}

@ -0,0 +1,14 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n, m, r;
scanf("%d%d%d", &n, &m, &r);
int m1 = numeric_limits<int>::max(), m2 = numeric_limits<int>::min();
for (int i = 0, x; i < n; i++) scanf("%d", &x), m1 = min(m1, x);
for (int i = 0, x; i < m; i++) scanf("%d", &x), m2 = max(m2, x);
printf("%d", max(r, r / m1 * m2 + r % m1));
return 0;
}

@ -0,0 +1,47 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
template <>
struct hash<pair<int, int>>
{
size_t operator()(const pair<int, int> &v) const
{
return *((long long *)&v);
}
};
int main()
{
unordered_set<pair<int, int>> S;
int n, m;
scanf("%d%d", &n, &m);
for (int i = 0; i < m; i++)
{
int x, y;
scanf("%d%d", &x, &y);
x--, y--;
if (x > y) swap(x, y);
S.insert({x, y});
}
vector<int> v;
for (long long i = 1; i * i <= n; i++)
if (n % i == 0)
{
v.push_back(i);
if (i != 1) v.push_back(n / i);
}
for (auto i : v)
if (n % i == 0)
if (all_of(S.begin(), S.end(), [&](const pair<int, int> &p) {
int x = (p.first + i) % n;
int y = (p.second + i) % n;
if (x > y) swap(x, y);
return S.count({x, y});
}))
{
puts("Yes");
return 0;
}
puts("No");
return 0;
}
Loading…
Cancel
Save