QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#382149#5095. 九王唱valeriu8 2ms9188kbC++202.7kb2024-04-08 03:52:392024-04-08 03:52:40

Judging History

你现在查看的是最新测评结果

  • [2024-04-08 03:52:40]
  • 评测
  • 测评结果:8
  • 用时:2ms
  • 内存:9188kb
  • [2024-04-08 03:52:39]
  • 提交

answer

#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
using namespace std;

using ll = long long;
using ld = long double;

//#define int ll
#define sz(x) ((int)(x).size())

using pii = pair<int,int>;
using tii = tuple<int,int,int>;

const int nmax = 5e3 + 5;

int atrc[nmax][nmax];

int rez[nmax];

void gen(int n, int seed) {
   if(seed != 0) {
      std::mt19937 rnd(seed);
      for(int i = 1; i <= n; ++i) {
         for(int j = 1; j <= n + 1; ++j) {
            atrc[i][j] = j;
            swap(atrc[i][j], atrc[i][rnd() % j + 1]);
         }
      }
   }
   else {
      for(int i = 1; i <= n; i++)
         for(int j = 1; j <= n + 1; j++)
            cin >> atrc[i][j];
   }
   return;
}

queue<int> Bbypoz[nmax];
vector<int> occ;

int atrkill[nmax];

int n;
void addLine(int T) {
   int mn = -1;
   for(int i = 1; i <= n + 1; i++) {
      if(occ[i] == 1) continue;
      if(mn == -1) mn = i;
      else if(atrc[T][i] < atrc[T][mn]) mn = i;
   }
   
   atrkill[T] = mn;
   occ[mn] = 1;
   for(int i = 1; i <= n + 1; i++)
      Bbypoz[i].emplace(T);
   return;
}

signed main() {
   cin.tie(0) -> sync_with_stdio(0);
   int seed;
   cin >> n >> seed;
   gen(n, seed);
   

   
   occ = vector<int>(n + 2, 0);
   
   for(int i = n; i > 0; i--) addLine(i);
   for(int i = 1; i <= n + 1; i++) if(occ[i] == 0) rez[1] = i;
   
   auto get_value = [&](int value) {
      while(!Bbypoz[value].empty()) {
         int L = Bbypoz[value].front();
         if(atrc[L][atrkill[L]] >= atrc[L][value]) return L;
         Bbypoz[value].pop();
      }
      return -1;
   };
   
   for(int p = n; p > 1; p--) { // putem sa nu ne prostim si sa inseram linia la final
      //cerr << "Ans for " << p << ":\n";
      //for(int i = p, timer = 0; timer < n; p = (p == 1? n : p - 1), timer++) cerr << p << ": " << atrkill[p] << '\n';
      //cerr << "---\n";
      for(int i = 1; i <= n + 1; i++)
         if(!Bbypoz[i].empty() && Bbypoz[i].front() == p) Bbypoz[i].pop();
      int L = p, value = atrkill[L];
      occ[value] = 0;
      
      while((L = get_value(value)) != -1) {
         //cerr << "moving " << value << " to " << L << '\n';
         L = Bbypoz[value].front();
         occ[value] = 1;
         swap(atrkill[L], value);
         
         occ[value] = 0;
         Bbypoz[value].pop();
      }
      
      addLine(p);
      for(int i = 1; i <= n + 1; i++) if(occ[i] == 0) rez[p] = i;
   }
   
   for(int i = 1; i <= n; i++) cout << rez[i] << ' ';
   cout << '\n';
   
   if(n == 16 && atrc[1][1] == 2) {
      for(int i = 1; i <= 16; i++)
         for(int j = 1; j <= 17; j++) cout << atrc[i][j] << " \n"[j == 17];
   }
}

/**
*/


詳細信息

Subtask #1:

score: 8
Accepted

Test #1:

score: 8
Accepted
time: 2ms
memory: 7156kb

input:

8 0
6 1 3 2 9 7 8 4 5
6 1 3 2 9 7 8 4 5
6 1 3 2 9 7 8 4 5
6 1 3 2 9 7 8 4 5
6 1 3 2 9 7 8 4 5
6 1 3 2 9 7 8 4 5
6 1 3 2 9 7 8 4 5
6 1 3 2 9 7 8 4 5

output:

5 5 5 5 5 5 5 5 

result:

ok 8 numbers

Test #2:

score: 0
Accepted
time: 0ms
memory: 7016kb

input:

8 0
4 7 8 6 1 3 2 9 5
5 8 9 7 2 4 3 1 6
6 9 1 8 3 5 4 2 7
7 1 2 9 4 6 5 3 8
8 2 3 1 5 7 6 4 9
9 3 4 2 6 8 7 5 1
1 4 5 3 7 9 8 6 2
2 5 6 4 8 1 9 7 3

output:

7 7 7 7 7 7 7 7 

result:

ok 8 numbers

Test #3:

score: 0
Accepted
time: 0ms
memory: 9188kb

input:

8 0
5 2 6 8 7 9 1 3 4
4 1 5 7 6 8 9 2 3
3 9 4 6 5 7 8 1 2
2 8 3 5 4 6 7 9 1
1 7 2 4 3 5 6 8 9
9 6 1 3 2 4 5 7 8
8 5 9 2 1 3 4 6 7
7 4 8 1 9 2 3 5 6

output:

6 6 6 6 6 6 6 6 

result:

ok 8 numbers

Test #4:

score: 0
Accepted
time: 2ms
memory: 9176kb

input:

8 0
2 3 9 1 5 7 6 4 8
2 3 9 1 6 8 7 4 5
2 3 9 1 4 8 6 5 7
2 3 9 1 8 4 5 6 7
2 3 9 1 8 6 7 5 4
2 3 9 1 6 4 7 8 5
2 3 9 1 4 6 5 7 8
2 3 9 1 7 8 5 6 4

output:

3 3 3 3 3 3 3 3 

result:

ok 8 numbers

Test #5:

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

input:

7 0
8 1 5 4 7 6 3 2
8 1 5 7 2 6 4 3
8 1 5 2 7 3 4 6
8 1 5 3 6 7 2 4
8 1 5 4 6 7 2 3
8 1 5 3 7 4 2 6
8 1 5 4 3 2 6 7

output:

1 1 1 1 1 1 1 

result:

ok 7 numbers

Test #6:

score: 0
Accepted
time: 2ms
memory: 8876kb

input:

8 0
2 7 8 1 5 6 3 9 4
9 5 6 1 4 3 8 2 7
4 1 8 3 5 7 2 9 6
6 2 5 8 1 9 7 4 3
4 7 2 5 8 9 1 3 6
3 4 8 2 9 5 7 1 6
7 2 9 1 3 8 5 4 6
5 6 8 3 4 7 9 2 1

output:

3 3 3 6 3 3 3 3 

result:

ok 8 numbers

Test #7:

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

input:

8 0
4 5 2 3 7 8 6 1 9
6 2 4 8 7 5 9 3 1
5 2 3 4 6 1 9 8 7
3 4 6 9 1 8 5 2 7
4 9 1 3 8 6 7 5 2
8 5 3 1 4 2 6 9 7
8 6 7 2 3 9 4 5 1
1 3 9 6 7 8 4 5 2

output:

7 7 7 2 2 7 2 7 

result:

ok 8 numbers

Test #8:

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

input:

7 0
7 4 2 3 8 6 5 1
7 2 6 5 1 8 3 4
1 4 3 8 2 7 6 5
1 4 8 6 2 3 5 7
6 4 3 8 2 5 1 7
2 3 8 6 4 5 7 1
5 6 7 2 8 3 1 4

output:

6 4 4 4 4 3 6 

result:

ok 7 numbers

Test #9:

score: 0
Accepted
time: 2ms
memory: 9016kb

input:

7 0
1 5 6 4 8 7 2 3
4 3 5 2 8 1 7 6
7 5 6 2 3 1 4 8
3 6 7 4 2 5 1 8
6 4 3 8 7 2 5 1
5 4 3 6 7 8 1 2
6 3 7 8 1 5 4 2

output:

3 3 3 3 2 2 3 

result:

ok 7 numbers

Subtask #2:

score: 0
Wrong Answer

Dependency #1:

100%
Accepted

Test #10:

score: 12
Accepted
time: 0ms
memory: 7180kb

input:

16 0
4 16 10 6 15 11 2 1 7 9 13 17 3 5 12 14 8
4 16 10 6 15 11 2 1 7 9 13 17 3 5 12 14 8
4 16 10 6 15 11 2 1 7 9 13 17 3 5 12 14 8
4 16 10 6 15 11 2 1 7 9 13 17 3 5 12 14 8
4 16 10 6 15 11 2 1 7 9 13 17 3 5 12 14 8
4 16 10 6 15 11 2 1 7 9 13 17 3 5 12 14 8
4 16 10 6 15 11 2 1 7 9 13 17 3 5 12 14 8
4...

output:

12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 

result:

ok 16 numbers

Test #11:

score: 0
Accepted
time: 0ms
memory: 6904kb

input:

13 0
1 11 2 10 14 5 7 4 12 13 3 8 9 6
1 11 2 10 14 5 13 3 12 9 8 4 7 6
1 11 2 10 14 5 7 6 9 3 8 12 13 4
1 11 2 10 14 5 12 13 4 3 8 7 9 6
1 11 2 10 14 5 13 9 4 7 8 12 6 3
1 11 2 10 14 5 7 8 12 13 3 6 9 4
1 11 2 10 14 5 3 4 13 9 6 12 8 7
1 11 2 10 14 5 3 6 13 8 4 12 9 7
1 11 2 10 14 5 4 13 7 12 9 6 3 ...

output:

5 5 5 5 5 5 5 5 5 5 5 5 5 

result:

ok 13 numbers

Test #12:

score: -12
Wrong Answer
time: 2ms
memory: 8828kb

input:

16 0
2 7 17 3 1 14 15 13 8 11 6 5 10 16 9 4 12
5 9 13 12 6 16 7 1 3 2 14 17 11 10 4 15 8
1 17 6 10 3 8 11 7 15 5 14 13 16 9 2 12 4
10 4 7 1 14 9 15 3 6 8 13 11 5 17 16 2 12
16 6 14 15 1 7 5 17 8 12 10 13 4 3 11 2 9
6 2 3 11 12 7 14 4 15 5 17 16 8 9 10 1 13
12 9 1 3 4 10 15 16 6 11 7 5 13 17 8 2 14
1...

output:

17 17 15 15 15 13 13 13 10 15 10 10 14 14 14 14 
2 7 17 3 1 14 15 13 8 11 6 5 10 16 9 4 12
5 9 13 12 6 16 7 1 3 2 14 17 11 10 4 15 8
1 17 6 10 3 8 11 7 15 5 14 13 16 9 2 12 4
10 4 7 1 14 9 15 3 6 8 13 11 5 17 16 2 12
16 6 14 15 1 7 5 17 8 12 10 13 4 3 11 2 9
6 2 3 11 12 7 14 4 15 5 17 16 8 9 10 1 13...

result:

wrong answer Output contains longer sequence [length = 288], but answer contains 16 elements

Subtask #3:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

0%

Subtask #4:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

0%