QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#943446 | #4923. 整数 | zbrc | Compile Error | / | / | C++14 | 2.5kb | 2025-03-19 20:58:13 | 2025-03-19 20:58:24 |
Judging History
This is the latest submission verdict.
- [2025-03-19 20:58:24]
- Judged
- Verdict: Compile Error
- Time: 0ms
- Memory: 0kb
- [2025-03-19 20:58:13]
- Submitted
answer
#include "integer.h"
#include <cstdio>
#include <cstdlib>
#include <cmath>
namespace SampleIntegerGrader
{
int n, p[1 << 21], S[1 << 21];
int currentPopcnt, ops;
double scoreof(const int s) {
if(s < 800000) return 1;
if(s <= 2000000) return 800000.0 / s;
if(s > 200000000) return 0;
return (9 - log10(s * 5)) / 5;
}
void reportResult(const std::vector<int> &answer) {
if((int)answer.size() != n)
puts("WA"), (void)printf("Invalid Answer length: expected %d, found %d\n", n, (int)answer.size()), exit(-1);
for(int i=0; i<n; i++)
if(answer[i] != p[i])
puts("WA"), (void)printf("Incorrect answer: p_%d is expected to be %d but found %d\n", i, p[i], answer[i]), exit(-1);
puts("OK"), (void)printf("Passed using %d operation(s): scoring %.3lf\n", ops, scoreof(ops));
}
void quitHalf(const int kth) {
puts("WA"), printf("Invalid query: Operation on %d violates range [0,%d]\n", kth, n - 1);
exit(-1);
}
int operate(const int kth) {
if(kth < 0 || kth >= n)
quitHalf(kth);
ops++;
S[p[kth]]++, currentPopcnt++;
for(int i = p[kth]; S[i] == 2; i++)
S[i] = 0, S[i + 1]++, currentPopcnt--;
return currentPopcnt;
}
void main() {
scanf("%d", &n);
for(int i = 0; i < n; i++) scanf("%d", p + i);
auto vans = findPermutation(n);
reportResult(vans);
}
}
int operate(const int kth) {
return SampleIntegerGrader::operate(kth);
}
int main() {
SampleIntegerGrader::main();
return 0;
}
#include<bits/stdc++.h>
#include "integer.h"
using namespace std;
const int N=5e3+10;
vector<int>ans;
int pre[N][N],p[N],a[N],suf[N];
int operate(const int i);
vector<int> findPermutation(int n){
int T=40;
for(int i=1;i<=n;i++)operate(i-1),p[i]=i;
for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)if(i!=j)pre[i][j]=1;
int lst=n,pos=0;
for(int i=1;i<=n;i++){
int x=operate(i-1);
if(x<=lst){pos=i;}
lst=x;
}
operate(pos-1);
operate(pos-1);
while(T-->0){
random_shuffle(p+1,p+1+n);
for(int i=1;i<=n;i++){
int x=operate(p[i]-1),y=operate(p[i]-1);
if(y>x){
for(int j=i+1;j<=n;j++)pre[p[i]][p[j]]=0;
}else{
for(int j=1;j<i;j++)pre[p[i]][p[j]]=0;
}
}
operate(pos-1);operate(pos-1);
}
for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)if(pre[i][j])suf[j]=i;
int cnt=0,X=pos;
while(X)a[X]=cnt++,X=suf[X];
for(int i=1;i<=n;i++)ans.push_back(a[i]);
return ans;
}
Details
implementer.cpp: In function ‘void integer_grader_F0F01B59EA9BF23E::generateToken()’: implementer.cpp:19:57: warning: format ‘%llX’ expects argument of type ‘long long unsigned int’, but argument 2 has type ‘std::mersenne_twister_engine<long unsigned int, 64, 312, 156, 31, 13043109905998158313, 29, 6148914691236517205, 17, 8202884508482404352, 37, 18444473444759240704, 43, 6364136223846793005>::result_type’ {aka ‘long unsigned int’} [-Wformat=] 19 | for(int i = 1; i <= 40; i++) printf("%llX", (rng() & 15)); | ~~~^ ~~~~~~~~~~~~ | | | | | std::mersenne_twister_engine<long unsigned int, 64, 312, 156, 31, 13043109905998158313, 29, 6148914691236517205, 17, 8202884508482404352, 37, 18444473444759240704, 43, 6364136223846793005>::result_type {aka long unsigned int} | long long unsigned int | %lX implementer.cpp: In function ‘void integer_grader_F0F01B59EA9BF23E::main()’: implementer.cpp:47:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 47 | scanf("%d", &n); | ~~~~~^~~~~~~~~~ implementer.cpp:49:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 49 | scanf("%d", p + i); | ~~~~~^~~~~~~~~~~~~ answer.code: In function ‘std::vector<int> findPermutation(int)’: answer.code:70:23: warning: ‘void std::random_shuffle(_RAIter, _RAIter) [with _RAIter = int*]’ is deprecated: use 'std::shuffle' instead [-Wdeprecated-declarations] 70 | random_shuffle(p+1,p+1+n); | ~~~~~~~~~~~~~~^~~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:61, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from answer.code:50: /usr/include/c++/14/bits/stl_algo.h:4491:5: note: declared here 4491 | random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last) | ^~~~~~~~~~~~~~ answer.code: In function ‘void SampleIntegerGrader::main()’: answer.code:37:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 37 | scanf("%d", &n); | ~~~~~^~~~~~~~~~ answer.code:38:49: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 38 | for(int i = 0; i < n; i++) scanf("%d", p + i); | ~~~~~^~~~~~~~~~~~~ /usr/bin/ld: /tmp/ccVBDtjf.o: in function `operate(int)': answer.code:(.text+0x2f0): multiple definition of `operate(int)'; /tmp/ccEmSB22.o:implementer.cpp:(.text+0x550): first defined here /usr/bin/ld: /tmp/ccVBDtjf.o: in function `main': answer.code:(.text.startup+0xc0): multiple definition of `main'; /tmp/ccEmSB22.o:implementer.cpp:(.text.startup+0xc0): first defined here collect2: error: ld returned 1 exit status