QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#247194 | #7619. Make SYSU Great Again I | ucup-team1055# | TL | 0ms | 3804kb | C++20 | 2.2kb | 2023-11-11 13:37:18 | 2023-11-11 13:37:20 |
Judging History
answer
#include <bits/stdc++.h>
#define rep(i,s,n) for(int i = int(s); i < int(n); i++)
#define rrep(i,s,n) for(int i = int(n) - 1; i >= int(s); i--)
#define all(v) (v).begin(), (v).end()
using ll = long long;
using ull = unsigned long long;
using ld = long double;
template<class T>
bool chmin(T &a, T b) {
if(a <= b) return false;
a = b;
return true;
}
template<class T>
bool chmax(T &a, T b) {
if(a >= b) return false;
a = b;
return true;
}
using namespace std;
void assertion(int n, int k, vector<pair<int,int>> p){
vector<vector<int>> a(n, vector<int>(n));
assert((int)p.size() == k);
rep(i,0,(int)p.size()){
assert (a[p[i].first][p[i].second] == 0);
a[p[i].first][p[i].second] = i + 1;
}
rep(i,0,n){
int g = 0;
int cnt = 0;
rep(j,0,n){
g = __gcd(a[i][j], g);
if(a[i][j] != 0) cnt++;
}
assert(cnt >= 2);
int g2 = 0;
cnt = 0;
rep(j,0,n){
g2 = __gcd(a[j][i], g2);
if (a[j][i] != 0) cnt++;
}
assert(cnt >= 2);
assert (g == g2);
}
}
int main() {
int n, k; cin >> n >> k;
vector<vector<int>> a(n, vector<int>(n));
int x = 0;
int y = 0;
rep(i,0,2*n){
if (i % 2 == 0){
a[x][y] = i+1;
x++;
x%=n;
}else{
a[x][y] = i+1;
if (i!=2*n-1) y++;
y%=n;
}
}
int piv = 2*n;
rep(i,0,n){
rep(j,0,n){
if (piv>=k) break;
if (a[i][j] == 0){
a[i][j] = piv+1;
piv++;
}
}
}
vector<pair<int,int>> ans(k);
rep(i,0,n){
rep(j,0,n){
if (a[i][j] != 0){
ans[a[i][j]-1] = pair(i, j);
}
}
}
//assertion(n,k,ans);
auto output = [&](){
rep(i,0,n){
rep(j,0,n){
cout << a[i][j] << ' ';
}
cout << endl;
}
};
//output();
rep(i,0,k){
cout << ans[i].first+1 << ' ' << ans[i].second+1 << '\n';
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3596kb
input:
3 6
output:
1 1 2 1 2 2 3 2 3 3 1 3
result:
ok The answer is correct.
Test #2:
score: 0
Accepted
time: 0ms
memory: 3592kb
input:
3 7
output:
1 1 2 1 2 2 3 2 3 3 1 3 1 2
result:
ok The answer is correct.
Test #3:
score: 0
Accepted
time: 0ms
memory: 3556kb
input:
2 4
output:
1 1 2 1 2 2 1 2
result:
ok The answer is correct.
Test #4:
score: 0
Accepted
time: 0ms
memory: 3568kb
input:
3 9
output:
1 1 2 1 2 2 3 2 3 3 1 3 1 2 2 3 3 1
result:
ok The answer is correct.
Test #5:
score: 0
Accepted
time: 0ms
memory: 3804kb
input:
10 20
output:
1 1 2 1 2 2 3 2 3 3 4 3 4 4 5 4 5 5 6 5 6 6 7 6 7 7 8 7 8 8 9 8 9 9 10 9 10 10 1 10
result:
ok The answer is correct.
Test #6:
score: 0
Accepted
time: 0ms
memory: 3536kb
input:
10 100
output:
1 1 2 1 2 2 3 2 3 3 4 3 4 4 5 4 5 5 6 5 6 6 7 6 7 7 8 7 8 8 9 8 9 9 10 9 10 10 1 10 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 2 3 2 4 2 5 2 6 2 7 2 8 2 9 2 10 3 1 3 4 3 5 3 6 3 7 3 8 3 9 3 10 4 1 4 2 4 5 4 6 4 7 4 8 4 9 4 10 5 1 5 2 5 3 5 6 5 7 5 8 5 9 5 10 6 1 6 2 6 3 6 4 6 7 6 8 6 9 6 10 7 1 7 2 7 3 7 4 7 5...
result:
ok The answer is correct.
Test #7:
score: 0
Accepted
time: 0ms
memory: 3516kb
input:
32 64
output:
1 1 2 1 2 2 3 2 3 3 4 3 4 4 5 4 5 5 6 5 6 6 7 6 7 7 8 7 8 8 9 8 9 9 10 9 10 10 11 10 11 11 12 11 12 12 13 12 13 13 14 13 14 14 15 14 15 15 16 15 16 16 17 16 17 17 18 17 18 18 19 18 19 19 20 19 20 20 21 20 21 21 22 21 22 22 23 22 23 23 24 23 24 24 25 24 25 25 26 25 26 26 27 26 27 27 28 27 28 28 29 28...
result:
ok The answer is correct.
Test #8:
score: -100
Time Limit Exceeded
input:
200000 400000