Submission #17759203


Source Code Expand

Copy
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define FORR2(x,y,arr) for(auto& [x,y]:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

ll ret=0;
int N,K;

ll pat(int v) {
	if(v<2 || v>2*N) return 0;
	if(v<=N+1) return v-1;
	return 2*N+1-v;
	
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>K;
	for(i=2;i<=2*N;i++) {
		ret+=pat(i)*pat(i-K);
	}
	cout<<ret<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}

Submission Info

Submission Time
Task B - Quadruple
User kmjp
Language C++ (GCC 9.2.1)
Score 400
Code Size 997 Byte
Status AC
Exec Time 7 ms
Memory 3652 KB

Compile Error

./Main.cpp: In function ‘void solve()’:
./Main.cpp:27:8: warning: unused variable ‘j’ [-Wunused-variable]
   27 |  int i,j,k,l,r,x,y; string s;
      |        ^
./Main.cpp:27:10: warning: unused variable ‘k’ [-Wunused-variable]
   27 |  int i,j,k,l,r,x,y; string s;
      |          ^
./Main.cpp:27:12: warning: unused variable ‘l’ [-Wunused-variable]
   27 |  int i,j,k,l,r,x,y; string s;
      |            ^
./Main.cpp:27:14: warning: unused variable ‘r’ [-Wunused-variable]
   27 |  int i,j,k,l,r,x,y; string s;
      |              ^
./Main.cpp:27:16: warning: unused variable ‘x’ [-Wunused-variable]
   27 |  int i,j,k,l,r,x,y; string s;
      |                ^
./Main.cpp:27:18: warning: unused variable ‘y’ [-Wunused-variable]
   27 |  int i,j,k,l,r,x,y; string s;
      |                  ^
./Main.cpp: In function ‘int main(int, char**)’:
./Main.cpp:7:28: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::__cxx11::basic_string<char>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
    7 | #define FOR(x,to) for(x=0;x<(to);x++)
      |                            ^
./Main.cpp:40:38: note: in expansion of macro ‘FOR’
   40 |  FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
      |                                      ^~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 2
AC × 21
Set Name Test Cases
Sample 00-sample-001.txt, 00-sample-002.txt
All 00-sample-001.txt, 00-sample-002.txt, 01-001.txt, 01-002.txt, 01-003.txt, 01-004.txt, 01-005.txt, 01-006.txt, 01-007.txt, 01-008.txt, 01-009.txt, 01-010.txt, 01-011.txt, 01-012.txt, 01-013.txt, 01-014.txt, 01-015.txt, 01-016.txt, 01-017.txt, 01-018.txt, 01-019.txt
Case Name Status Exec Time Memory
00-sample-001.txt AC 7 ms 3488 KB
00-sample-002.txt AC 2 ms 3564 KB
01-001.txt AC 3 ms 3560 KB
01-002.txt AC 2 ms 3604 KB
01-003.txt AC 3 ms 3608 KB
01-004.txt AC 4 ms 3576 KB
01-005.txt AC 2 ms 3492 KB
01-006.txt AC 2 ms 3492 KB
01-007.txt AC 4 ms 3548 KB
01-008.txt AC 2 ms 3500 KB
01-009.txt AC 3 ms 3652 KB
01-010.txt AC 3 ms 3612 KB
01-011.txt AC 3 ms 3496 KB
01-012.txt AC 4 ms 3652 KB
01-013.txt AC 2 ms 3612 KB
01-014.txt AC 3 ms 3612 KB
01-015.txt AC 4 ms 3612 KB
01-016.txt AC 3 ms 3648 KB
01-017.txt AC 2 ms 3564 KB
01-018.txt AC 2 ms 3544 KB
01-019.txt AC 3 ms 3580 KB