Submission #713241
Source Code Expand
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define FORD(x,y,z) for(int x=y;x>=z;x--)
#define MSET(x,y) memset(x,y,sizeof(x))
#define FOR(x,y) for(__typeof(y.begin()) x=y.begin();x!=y.end();x++)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define SZ size()
#define M 10001
void RI(){}
template<typename... T>
void RI( int& head, T&... tail ) {
scanf("%d",&head);
RI(tail...);
}
using namespace std;
typedef long long LL;
typedef pair<int,int> P;
int n,m;
short dis[M][M];
vector<P> e[M];
queue<P> q;
int main()
{
int x,y,z;
int cur;
int nx,ny;
while(~scanf("%d %d",&n,&m))
{
MSET(dis, 0);
REP(i,0,n) e[i].clear();
REP(i,1,m)
{
RI(z,x,y);
e[x].PB( MP(y,z) );
e[y].PB( MP(x,z) );
}
dis[0][0] = 1;
q.push( MP(0,0) );
while(!q.empty())
{
cur = q.front().F;
x = q.front().S;
q.pop();
FOR(i,e[cur])
{
nx = i->F;
ny = i->S + x;
if(ny>n) continue;
if(!dis[nx][ny])
{
dis[nx][ny] = dis[cur][x]+1;
q.push( MP(nx,ny) );
}
}
}
LL mn, tmp;
REP(i,0,n-1)
{
mn = 1LL << 61;
REP(j,0,n-1) if(dis[i][j])
{
tmp = dis[i][j];
if(j>=2) tmp += (LL)(j-1)*j*(2*j-1)/6;
mn = min(mn, tmp);
}
printf("%lld\n",mn-1);
}
}
return 0;
}
Submission Info
Submission Time
2016-04-30 22:12:02+0900
Task
C - 高橋くんと不思議な道
User
Nekosyndrome
Language
C++14 (GCC 5.4.1)
Score
0
Code Size
1373 Byte
Status
WA
Exec Time
4224 ms
Memory
198784 KiB
Compile Error
./Main.cpp: In function ‘void RI(int&, T& ...) [with T = {int, int}]’:
./Main.cpp:15:5: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&head);
^
./Main.cpp: In function ‘void RI(int&, T& ...) [with T = {int}]’:
./Main.cpp:15:5: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
./Main.cpp: In function ‘void RI(int&, T& ...) [with T = {}]’:
./Main.cpp:15:5: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
Judge Result
Set Name
Sample
Subtask1
Score / Max Score
0 / 0
0 / 100
Status
Set Name
Test Cases
Sample
sample1.txt, sample2.txt, sample3.txt
Subtask1
sample1.txt, sample2.txt, sample3.txt, A1.txt, A10.txt, A11.txt, A12.txt, A13.txt, A14.txt, A15.txt, A16.txt, A17.txt, A2.txt, A3.txt, A4.txt, A5.txt, A6.txt, A7.txt, A8.txt, A9.txt, B1.txt, B10.txt, B11.txt, B12.txt, B13.txt, B14.txt, B15.txt, B16.txt, B17.txt, B18.txt, B19.txt, B2.txt, B20.txt, B21.txt, B22.txt, B23.txt, B24.txt, B25.txt, B26.txt, B4.txt, B5.txt, B6.txt, B7.txt, B8.txt, B9.txt
Case Name
Status
Exec Time
Memory
A1.txt
WA
271 ms
195840 KiB
A10.txt
AC
579 ms
198528 KiB
A11.txt
AC
577 ms
198528 KiB
A12.txt
WA
3085 ms
196224 KiB
A13.txt
TLE
4223 ms
196224 KiB
A14.txt
TLE
4223 ms
196224 KiB
A15.txt
TLE
4224 ms
196352 KiB
A16.txt
TLE
4223 ms
196352 KiB
A17.txt
TLE
4219 ms
196352 KiB
A2.txt
AC
282 ms
196096 KiB
A3.txt
AC
547 ms
198528 KiB
A4.txt
TLE
4219 ms
196224 KiB
A5.txt
TLE
4223 ms
198784 KiB
A6.txt
TLE
4223 ms
198528 KiB
A7.txt
TLE
4224 ms
198656 KiB
A8.txt
AC
439 ms
196224 KiB
A9.txt
TLE
4223 ms
196224 KiB
B1.txt
TLE
4223 ms
196352 KiB
B10.txt
TLE
4223 ms
196224 KiB
B11.txt
TLE
4223 ms
196224 KiB
B12.txt
TLE
4223 ms
196224 KiB
B13.txt
TLE
4223 ms
196224 KiB
B14.txt
TLE
4222 ms
196224 KiB
B15.txt
TLE
4223 ms
196224 KiB
B16.txt
TLE
4223 ms
196224 KiB
B17.txt
TLE
4223 ms
196480 KiB
B18.txt
TLE
4223 ms
196352 KiB
B19.txt
TLE
4223 ms
196224 KiB
B2.txt
TLE
4223 ms
196352 KiB
B20.txt
TLE
4219 ms
196224 KiB
B21.txt
TLE
4223 ms
196224 KiB
B22.txt
TLE
4223 ms
196224 KiB
B23.txt
TLE
4223 ms
196224 KiB
B24.txt
TLE
4223 ms
196224 KiB
B25.txt
TLE
4219 ms
196224 KiB
B26.txt
WA
3507 ms
196224 KiB
B4.txt
TLE
4223 ms
196224 KiB
B5.txt
TLE
4223 ms
196224 KiB
B6.txt
TLE
4223 ms
196224 KiB
B7.txt
TLE
4222 ms
196224 KiB
B8.txt
TLE
4223 ms
196224 KiB
B9.txt
TLE
4223 ms
196224 KiB
sample1.txt
AC
310 ms
195840 KiB
sample2.txt
AC
267 ms
195840 KiB
sample3.txt
AC
307 ms
195840 KiB