QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#638727#9439. Aim Highucup-team1338#AC ✓1ms4092kbC++201.4kb2024-10-13 16:44:592024-10-13 16:45:00

Judging History

This is the latest submission verdict.

  • [2024-10-13 16:45:00]
  • Judged
  • Verdict: AC
  • Time: 1ms
  • Memory: 4092kb
  • [2024-10-13 16:44:59]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
void solve();
int main(){
    ios::sync_with_stdio(false);int T=1;
    cin>>T;
    while(T--)solve();
}
const int B=105;
ll f[B+8][B+200];
vector<tuple<int,int,int,int,int,int>>ans;
void up(int x,int y,int o) {
    f[x][y+B]--,f[x+1][y+B]--,f[x+o][y+1+B]++;
    if(o==1)ans.emplace_back(x,y,x+1,y,x+o,y+1);
    else ans.emplace_back(x+1,y,x,y,x+o,y+1);
}

int vis[200];

void solve(){
    int n;
    cin>>n;
    if(n>=5){
        cout<<-1<<'\n';
        return;
    }
    vector<tuple<int,int,int>>v={
        {5,3,1},{4,2,1},{6,2,0},{3,1,1},{4,1,1},{6,1,0},{7,1,0},
        {2,0,1},{3,0,1},{3,0,1},{5,0,1},{5,0,0},{8,0,0},{7,0,0},{7,0,0},
        {2,-1,1},{2,-1,1},{3,-1,1},{4,-1,1},{8,-1,0},{8,-1,0},{7,-1,0},{6,-1,0},
        {1,-2,1},{2,-2,1},{3,-2,0},{4,-2,0},{9,-2,0},{8,-2,0},{7,-2,1},{6,-2,1},
        {1,-3,1},{2,-3,1},{4,-3,0},{9,-3,0},{8,-3,0},{6,-3,1},
        {1,-4,1},{9,-4,0}
    };
    for(int i=0;i<=100;i++)for(int j=-5;j<=0;j++)f[i][j+B]=1;
    while(true) {
        int p=0;
        for(int i=0;i<v.size();i++) {
            if(vis[i])continue;
            auto[x,y,z]=v[i];
            if(f[x][y+B]&&f[x+1][y+B]&&!f[x+z][y+1+B])up(x,y,z),p=i,vis[i]=1;
            if(p)break;
        }
        if(!p)break;
    }
    cout<<ans.size()<<'\n';
    for(auto[q,w,e,r,t,y]:ans)cout<<q<<' '<<w<<' '<<e<<' '<<r<<' '<<t<<' '<<y<<'\n';
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 4092kb

input:

1
1

output:

39
2 0 3 0 3 1
5 0 6 0 6 1
9 0 8 0 8 1
2 -1 3 -1 3 0
3 0 4 0 4 1
3 1 4 1 4 2
4 -1 5 -1 5 0
9 -1 8 -1 8 0
8 0 7 0 7 1
7 1 6 1 6 2
7 -1 6 -1 6 0
6 0 5 0 5 1
1 -2 2 -2 2 -1
4 -2 3 -2 3 -1
2 -1 3 -1 3 0
10 -2 9 -2 9 -1
7 -2 8 -2 8 -1
9 -1 8 -1 8 0
1 -3 2 -3 2 -2
5 -3 4 -3 4 -2
5 -2 4 -2 4 -1
10 -3 9 -3 ...

result:

ok Output is valid. OK

Test #2:

score: 0
Accepted
time: 1ms
memory: 3812kb

input:

6
1
2
3
4
5
6

output:

39
2 0 3 0 3 1
5 0 6 0 6 1
9 0 8 0 8 1
2 -1 3 -1 3 0
3 0 4 0 4 1
3 1 4 1 4 2
4 -1 5 -1 5 0
9 -1 8 -1 8 0
8 0 7 0 7 1
7 1 6 1 6 2
7 -1 6 -1 6 0
6 0 5 0 5 1
1 -2 2 -2 2 -1
4 -2 3 -2 3 -1
2 -1 3 -1 3 0
10 -2 9 -2 9 -1
7 -2 8 -2 8 -1
9 -1 8 -1 8 0
1 -3 2 -3 2 -2
5 -3 4 -3 4 -2
5 -2 4 -2 4 -1
10 -3 9 -3 ...

result:

ok Output is valid. OK

Extra Test:

score: 0
Extra Test Passed